Friday 15 March 2013

wpf - How to disable a databound ListBox item based on a property value? -


Does anybody know how and how to base the value of objects in a databound ListBox Can a property be disabled?

I like DataTrigger which, when a specific property is false , disables this item (making it impossible to choose) without ListBox .

  & lt; ListBox & gt; In other things is affecting. & Lt; ListBox.ItemTemplate & gt; & Lt; DataTemplate & gt; & Lt; TextBlockName = "textBlock" text = "{binding description}" /> & Lt; DataTemplate.Triggers & gt; & Lt; Datatiger binding = "{binding ISEnabled}" value = "wrong" & gt; ?? & Lt; / DataTrigger & gt; & Lt; /DataTemplate.Triggers> & Lt; / DataTemplate & gt; & Lt; /ListBox.ItemTemplate> & Lt; / ListBox & gt; You can use ItemContainerStyle:  
  & Lt; ListBox & gt; & Lt; ListBox.ItemContainerStyle & gt; & Lt; Style TargetType = "{x: Type ListboxItem}" & gt; & Lt; Style.Triggers & gt; & Lt; Data Trigger Binding = "{Bearing YourPropertyName}" value = "False" & gt; & Lt; Setter property = "iced" value = "wrong" /> & Lt; / DataTrigger & gt; & Lt; /Style.Triggers> & Lt; / Style & gt; & Lt; /ListBox.ItemContainerStyle> & Lt; / ListBox & gt;  

No comments:

Post a Comment