.net 3.5 - How to bind inverse boolean properties in WPF? -


I have an object that has a IsReadOnly property if this property is true, then I I would like to set the IsEnabled property on the button (for example).

I have to believe that I can do it as easily as IsEnabled = "{Binding Path =! IsReadOnly}" but it flies with WPF does not.

Do I have all the style settings? Just as any other bowl is set inversion of any other hair, it seems very simple enough for some.

  & gt; button. Style & gt; & Lt; Style TargetType = "{x: type button}" & gt; & Lt; Style.Triggers & gt; & Lt; DataTrigger Binding = "{Binding Path = IsReadOnly}" Value = "True" & gt; & Lt; Setter property = "iced" value = "wrong" /> & Lt; / DataTrigger & gt; & Lt; Datatrigger binding = "{binding path = iside only}" value = "wrong" & gt; & Lt; Setter Property = "Iceded" value = "true" /> & Lt; / DataTrigger & gt; & Lt; /Style.Triggers> & Lt; / Style & gt; & Lt; /Button.Style>  

You can use a ValueConverter that alters a bool property for you is.

[Value Conversion (Type (Bull), Typef (Bull)) Public Category Inverbosbonan Converter: IValueConverter {#region IValueConverter Member Public Object Convert (Object Value, Type Target Type, Object Parameter, System Globilization. (TargetType! = Typeof (bool)) New Invalid Operation exception throw ("Target should be a Boolean"); Back (Bool) Value;} Public Object Convertback (Object Value, Type Type, Object Parameter, System. Globalization. Cultural Information Culture) {New Notport Supported Exception ();} #endregion}


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -