我在作为组合框项模板一部分的文本框元素内具有以下XAML。ComboBox的items源被设置为具有布尔属性acceptsInput的对象列表,所有操作都很好,但我无法让此触发器触发,是否必须执行其他操作。
<TextBox.Style> <Style TargetType="TextBox"> <Style.Triggers> <DataTrigger Binding="{Binding AcceptsInput}" Value="False" > <Setter Property="Visibility" Value="Hidden"> </Setter> </DataTrigger> </Style.Triggers> </Style> </TextBox.Style>
是否在具有AcceptsInput属性的ViewModel类中正确实现了InotifyPropertyChanged?
它应该是这样的:
public class MyClass: INotifyPropertyChanged { private bool _acceptsInput; public bool AcceptsInput { get { return _acceptsInput; } set { _acceptsInput = value; OnPropertyChanged("AcceptsInput"); } } ... }