I would like to filter a TreeView, but I can't find any solution for Xamarin.Forms. Is it possible or not ?
Thank you :)
2 Answers, 1 is accepted
0
Lance | Senior Manager Technical Support
Telerik team
answered on 08 Sep 2020, 01:31 PM
Hi Bra,
The RadTreeView doesn't use FilterDescriptors or internal data segregation. Therefore, you can use normal filtering with LINQ.
For example:
//---------------------Setup------------------------- //// Keep a separate ObservableCollection for TreeView
ObservableCollection<Car> originalData = ...;
ObservableCollection<Car> tvData = new ObservableCollection<Car>();
MyTreeView.ItemsSource = tvData;
//---------------------All Items---------------------- //// show all the items in the Treeviewforeach(var car in originalData)
tvData.Add(car);
//-------------------Filtered Items---------------------- //// Clear the previous list
tvData.Clear();
// filter out the items you wantvar filteredCars = originalData.Where(i => i.Make == "Mercedes Benz");
// show them in the Treeviewforeach(var car in filteredCars)
tvData.Add(car);
Regards,
Lance | Manager Technical Support
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.