开发者

WPF Datatrigger for an item template

I have the following xaml inside a text box eleme开发者_JAVA技巧nt that is part of a combo box item template. The combobox's items source is set to a list of objects that have a boolean property AcceptsInput everything works great but I can't get this trigger to fire do I have to do something else.

<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>


Are you correctly implementing INotifyPropertyChanged in the viewmodel class with the AcceptsInput property?

It should look something like this:

public class MyClass: INotifyPropertyChanged
{

    private bool _acceptsInput;
    public bool AcceptsInput
    {
        get { return _acceptsInput; }
        set
        {

            _acceptsInput = value;
            OnPropertyChanged("AcceptsInput");
        }
    }
...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜