You need to raise the PropertyChanged
event when you set Foo in your DataContext
. Normally, it would look something like:
public class ViewModel : INotifyPropertyChanged
{
private bool _foo;
public bool Foo
{
get { return _foo; }
set
{
_foo = value;
OnPropertyChanged("Foo");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
var propertyChanged = PropertyChanged;
if (propertyChanged != null)
{
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
If you call Foo = someNewvalue
, the PropertyChanged
event will be raised and your UI should be updated
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…