Reputation:
I need to perform a filter search with dynamic fields and i am not sure about the best way to do this.
We have a lot of documents with different fields and would like these to be used like a filter search.
Can someone point me in the right direction?
Upvotes: 1
Views: 2150
Reputation: 2064
If you are using MVVM pattern. Here are the steps:
ObservableCollection<ItemType>
for each of the drop down lists in your ViewModel.SelectedType1, SelectedType2
etc. properties for selected values corresponding to each drop down list.ObservableCollection<SearchResultType> SearchResults
in the ViewModel which holds the search results for the given search.SearchCommand
property in the ViewModel which executes the Search
method.Search
method which essentially makes a web request call or a local database search query depending on your requirement. This search method now has access to all the drop down selections/text typed by the user.SearchResults
collection.SearchResults
collection to the ListView.ItemsSource
in the View.SearchCommand
to the search action button (top right button in your view).Happy coding!
Upvotes: 1