Попробуйте использовать в своем классе interface INotifyPropertyChanged
, который содержит ваш логический тип.
Например,
public class DemoCustomer : INotifyPropertyChanged
{
private bool _selected;
public bool Selected
{
get
{
return _selected;
}
set
{
_selected = value;
NotifyPropertyChanged("Selected");
}
}
public event PropertyChangedEventHandler PropertyChanged;
// This method is called by the Set accessor of each property.
// The CallerMemberName attribute that is applied to the optional propertyName
// parameter causes the property name of the caller to be substituted as an argument.
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
Затем вы слушаете это событие.
var d = new DemoCustomer();
d.PropertyChanged += (s,e) => { if(e.PropertyName = "Selected" && ((DemoCustomer)s).Selected) { //do something}};