Alex Rivera | Logout

Having hardcoded text with a binding in a TextBlock

Asked 2009-04-25T16:06:45.080
71

In WPF, is there any way to have the Text property of a TextBlock to contain both hard coded text and a specific binding?

What I have in mind is something along the lines of the following (ofcourse, the below doesn't compile):

<TextBlock Text="Number of Fans: {Binding Artist.Fans.Count}"></TextBlock>
Edit
Report

1 Answer

6

Use Binding.StringFormat:

<TextBlock Text="{Binding Artist.Fans.Count, StringFormat='Number of Fans: {0}'}"/>
answered 2009-04-25T16:16:35.883

Your Answer