[英]ScrollTo not working with grouped ListView in Xamarin.Forms
[英]Searching in grouped ListView in Xamarin.Forms
我按照本指南在Xamarin.Forms
創建了一個分組的ListView
。 這樣做,給出以下Property
,該Property
被綁定為ListView
的ItemSource
:
DevicesGrouped = new ObservableCollection<Grouping<string, Device>>(sorted);
一切正常,包括分組功能。
要搜索(從而過濾)列表中的條目,我嘗試實現此模式 :
this.ItemsSource = DevicesGrouped
.Where (x => x.Name.ToLower ()
.Contains (filter.ToLower ()));
問題是,由於對象駐留在Groupings
,因此我無法訪問Device
的屬性。 我只能訪問DevicesGrouped
的Key
,在這種情況下,它是一個Manufacturer
,我想搜索Name
。 搜索Key
的問題還在於, ListView
滾動到Key
的位置,從而將ListView
的元素隱藏在分組標題后面。
我的問題是,如何訪問ObservableCollection
的Grouped屬性?
我已經嘗試保留我在過濾時使用的List,但這樣做,應用程序崩潰,因為ListView
本身已啟用Groupings
。
我在這里先向您的幫助表示感謝。
我找到了我的問題的答案,如果其他人遇到同樣的問題,我會發布。
過濾Grouped ListView時,請執行以下操作:
_groupedDeviceList.ItemsSource =
DevicesGrouped.Where(o => o.Any(p => p.Name.ToLower().Contains(filter.ToLower())));
_groupedDeviceList
當然是你自己的列表。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.