Friday 15 July 2011

wpf - DataTrigger on a Property of a Binding -


I have a property labeled on user control in which the string of this binding is the data type of the data contained in the format property Should be set on the basis of which is the property of the label's material. So if the property is bound to a date property in my view-model, then I want to specify the string format in a data trigger. What I have tried here, but string formatting is not recognized. Am I forgetting something or am I doing it wrong? Any advice would be greatly appreciated.

  & lt; Label x: name = "myLabel" content = "{binding path = myProperty}" & gt; & Lt; Label.Style & gt; & Lt; Style & gt; & Lt; Style.Triggers & gt; & Lt; DataTrigger binding = "{binding element name = myLabel, path = content. Binding}" value = "{x: type of arrangement: date time}" & gt; & Lt; Setter Property = "String Format" value = "DD / MM / YYY" /> & Lt; / DataTrigger & gt; & Lt; /Style.Triggers> & Lt; / Style & gt; & Lt; /Label.Style>   

Why not use a converter?

  & lt; Label content = "{binding path = myProperty, converter = {StaticResource MyContentConverter}}" & gt;    

No comments:

Post a Comment