I got 3 listviews. The itemsources is bound to an ObservableCollection the person class has an integer property(with INotifyPropertyChanged) “teamID”. Now I want to filter the listviews depending on the team they are in, is there a way to do it easy(I know 2 solutions for it but I think they are not good, 1 is to make 3 ObservableCollection but that will be complex to keep track and transfer all the persons to the right ObservableCollection , or use a trigger like Visibility to Visible if the teamID is the right teamID^^)
I got 3 buttons and if I select an item(person) on any of the listviews, depending on the button clicked that person teamID will change. (But I also want him to change to the right listview depending on teamID)
Hope you understand, otherwise feel free to ask for more details.
I think It is not possible to do it without writing some code.
I would use
CollectionViewinstead of binding the collection directly to the ListView. This is what WPF will do internally, but creating them by your own you will have control to many things like sort and of course filters.Create them using
CollectionViewSource.GetDefaultView(yourCollection).Apply the filters and on the setter of your team id property do a
CollectionView.Refresh()when team id changes. If you don’t have too many data this is not a big issue. But on a lot of dataRefresh()on three views might be a little heavy.EDIT:
I forgot to tell you that you must set the source on each one of your ListViews to the corresponding CollectionView but I think this is obvious.