Reputation: 1535
I'm wondering if there is special syntax to bind text concatenated with existing text.
Something like this.
<TextBlock Grid.Row="0" Name="tbGroupMembershipCaption"
Text="The following users have access to export to '{Binding TargetName}'."/>
Clearly, this doesn't work.
What is the best practice?
Using SL4.
Upvotes: 2
Views: 1893
Reputation: 563
This is what worked for me. Close to the last one but that one would not work for me.
<TextBlock HorizontalAlignment="Right" Grid.Column="2" Grid.Row="1" Text="{Binding CreatedBy, StringFormat=By \{0\}}"/>
Upvotes: 0
Reputation: 185225
Use StringFormat
on the Binding
.
WPF: {Binding SomeProp, StringFormat={}Head text {0} Tail text}
WPF/SL: {Binding SomeProp, StringFormat='{}Head text {0} Tail text'}
WPF/SL Alt.: {Binding SomeProp, StringFormat=Head text \{0\} Tail text}
Upvotes: 8
Reputation: 34359
Text="{Binding TargetName, StringFormat=The following users have access to export to \{0\}}"
See http://msdn.microsoft.com/en-us/library/system.windows.data.bindingbase.stringformat.aspx for more details.
Upvotes: 3
Reputation: 24766
Perhaps this:
Text="{Binding TargetName, StringFormat=The following users have access to export to '\{0\}'."
Upvotes: 1