I'm trying to set a TextBlock.Text
in a trigger. Everything works fine if I bind property in the setter, but how do I "concat" a string and a property?
For instance, I've got a Date
property. I want the text to be "The date is 9/21/2017."
So far, I managed to show "9/21/2017", but can't figure out how to concat a string before it (I present you only the "interesting part"):
<DataTrigger Binding="{Binding State}" Value="{x:Static model:Croissant+CroissantState.IsUsed}">
<Setter Property="Text">
<Setter.Value>
<MultiBinding StringFormat="{}{0:d}">
<Binding Path="Date" />
</MultiBinding>
</Setter.Value>
</Setter>
</DataTrigger>
Any advice on how to bind a string literal? Do I have to use a converter for this or is there an "easy way"?
For anyone who doesn't read the comment, and thanks to Ayyappan Subramanian, the solution is:
<DataTrigger Binding="{Binding State}" Value="{x:Static model:Croissant+CroissantState.IsUsed}">
<Setter Property="Text">
<Setter.Value>
<Binding Path="Date" StringFormat="The date is {0:d}" />
</Setter.Value>
</Setter>
</DataTrigger>