Answer the question
In order to leave comments, you need to log in
How to create filtering on bound collection in WPF?
Good afternoon! Faced such a problem. In my project, a collection of its "Person" class is attached to the ComboBox.
How can I disable some items in the collection when the RadioButton is clicked?
Answer the question
In order to leave comments, you need to log in
I can offer a solution that I myself, having found on the open spaces of the network, began to use and was satisfied.
1. We start a collection that will be our source
public ObservableCollection<Person> FilteredCollection
{
get
{
return new ObservableCollection<Person>(PersonCollection.Where(i => FilteredCheck(i)));
}
}
public bool FilteredCheck(DemandHead item)
{
bool Accept=true;
// организовываем проверку как вашей душе удобно
}
// И дальше при изменении фильтра оповещаем View об изменении данных
public bool IsFilterEnabled
{
get
{
return _IsFilterEnabled;
}
set
{
_IsFilterEnabled = value;
base.OnPropertyChanged("IsFilterEnabled");
base.OnPropertyChanged("FilteredCollection");
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question