0
我有一个Foo
类:绑定Button.IsEnabled一个属性在TextBox的数据源
public class Foo
{
public string Value { get; set; }
public string IsDirty { get; private set; }
}
和我有一个TextBox
和Button
势必Foo
XAML:
<TextBox Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}" ... />
<Button IsEnabled="{Binding IsDirty}" ... />
一旦TextBox
中的文本被更改(在KeyDown
上更新),Foo.IsDirty
变为true(直到单击保存按钮)。
现在,Button.IsEnabled
在Foo.IsDirty
更改时没有更改。
我该如何更改Button
上的绑定,以便它在Foo.IsDirty = true
之后立即生效,反之亦然?
谢谢!
我担心这可能是问题。不幸的是,Foo类扩展了一个类,该类是我无法修改的框架的一部分(并且IsDirty是框架的一部分),所以如果该属性没有通知,我想我必须找出其他的东西。谢谢! –
为什么不创建一个从你的基类和'INotifyPropertyChange'扩展的类,并且'Foo'继承了它? – Rachel
如果您可以更新'Value'属性的setter的代码,那么您可以在'Value'属性的setter中引发'OnPropertyChanged(“IsDirty”);'那里。 –