반응형
정의
💡
검색용 뷰
(Android에는 취소 버튼이 없습니다.)
사용법
생성
SearchBar searchBar = new SearchBar
{
Placeholder = "Search items...",
PlaceholderColor = Color.Orange,
TextColor = Color.Orange,
TextTransform = TextTransform.Lowercase,
HorizontalTextAlignment = TextAlignment.Center,
FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(SearchBar)),
FontAttributes = FontAttributes.Italic
};이벤트 처리
searchBar.TextChanged += (sender, e) =>
{
collectionView.ItemsSource = GetSearchResults(e.NewTextValue);
};private List<CustomPickerItems> GetSearchResults(string queryString)
{
var normalizedQuery = queryString?.ToLower() ?? "";
return CustomPickerViewModel.CustomPickerItems.Where(f =>
f.name.ToLowerInvariant().Contains(normalizedQuery)).ToList();
}
속성
- CancelButtonColor : 우측 취소버튼 색
- Placeholder
- SearchCommand : 검색 동작 바인딩
- SearchCommandParameter : 전달하는 매개변수
Reference
Xamarin.Forms SearchBar - Xamarin
샘플 다운로드 Download the sample 는 Xamarin.Forms The Xamarin.Forms The 다음 스크린샷에서 SearchBar 검색을 시작 하는 데 사용 되는 사용자 입력 컨트롤입니다. SearchBar is a user input control used to initiating a search. SearchBar컨트롤은 자리 표시자 텍스트, 쿼리 입력, 검색 실행 및 취소를 지원 합니다.

SearchBar 클래스 (Xamarin.Forms)
검색 상자를 제공하는 A View 컨트롤입니다. View control that provides a search box. [Xamarin.Forms.RenderWith(typeof(Xamarin.Forms.Platform._SearchBarRenderer))] public class SearchBar : Xamarin.Forms.InputView, Xamarin.Forms.IElementConfiguration , Xamarin.Forms.Internals.IFontElement, Xamarin.Forms.ISearchBarController type SearchBar = class inherit InputView interface IFontElement interface ISearchBarController interface IElementConfiguration 상속 특성 구현 다음 예제에서는 기본 사용을 보여 줍니다. The following example shows a basic use.

반응형
'프로그래밍 > App 개발' 카테고리의 다른 글
| [Xamarin] Custom Bottom Sheet (0) | 2020.10.22 |
|---|---|
| [Xamarin] Custom Layout (0) | 2020.10.21 |
| [Xamarin] Messaging Center (0) | 2020.10.20 |
| [Xamarin] UIModalPresentationStyle (0) | 2020.10.20 |
| Syncronous, Asyncronous (오늘의 만나 iOS를 만들며 느낀점) (0) | 2020.10.02 |
Uploaded by Notion2Tistory v1.0.0