I'm struggling with binding to the checkbox of a tree view item ... I have the following class:
public class Filter : INotifyPropertyChanged
{
public string Key { get; set;}
public string Name { get; set; }
public FilterCollection Filters { get; set; }
private bool _count = false;
public bool Count
{
get
{
return _count;
}
set
{
if (_count != value)
{
_count = value;
this.NotifyPropertyChanged("Count");
}
}
}
private bool _isChecked = false;
public bool IsChecked
{
get
{
return _isChecked;
}
set
{
if (_isChecked != value)
{
_isChecked = value;
this.NotifyPropertyChanged("IsChecked");
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public Filter()
{
this.Filters = new FilterCollection();
}
}
I have a collection of these objects called FilterCollection of type ObservableCollection<Filter> ... what is the best and easiest way to bind the property IsChecked to the CheckState of the treeview item?
I'm binding the datasource in the code-behind, if that matters.
Silverlight newbie, my apologies.