Background
I followed this guide to create a grouped ListView
in Xamarin.Forms
. Doing so, the following Property
is given which is bound as the ItemSource
of the ListView
:
DevicesGrouped = new ObservableCollection<Grouping<string, Device>>(sorted);
Everything works just fine, including the grouping functionality.
To search (and thereby filter) the entries in the list, I have tried to implement this pattern:
this.ItemsSource = DevicesGrouped
.Where (x => x.Name.ToLower ()
.Contains (filter.ToLower ()));
The issue
The problem is, that I do not have access to the properties of the Device
as the objects reside in Groupings
. I can only access the Key
of the DevicesGrouped
which, in this case, is a Manufacturer
, where I want to search for the Name
. The problem in searching for the Key
is also, that the ListView
scrolls to the position of the Key
and thus hides the elements in the ListView
behind the grouping header.
My question is thus, how would one access the properties of the ObservableCollection
which is Grouped?
I have tried keeping a List which I use when I filter, but doing so, the app crashes, since Groupings
are enabled on the ListView
itself.
Thanks for the help in advance.