Stringformat concatenates databinding and resource's value
Yes, you can. Simply use a MultiBinding
.
The MSDN article on StringFormat
has an example.
In your case, the code would look something like this:
<TextBlock> <TextBlock.Text> <MultiBinding StringFormat="{}{0} {1}"> <Binding Source="{x:Static res:Strings.TitleDescription}"/> <Binding Path="Description"/> </MultiBinding> </TextBlock.Text> </TextBlock>
I've seen the MultiBinding
answer in several places now, and it is almost never necessary to use it. You can define your resource as the string format instead, and as long as there is only one string format argument, no MultiBinding
is required. Makes the code a lot more succinct:
<TextBlock Text="{Binding Description, StringFormat={x:Static res:Strings.TitleDesc}}" />
And the TitleDesc
resource is obviously "Building: {0}"
.