Mark Carpenter
Mark Carpenter

Reputation: 17775

Can I set the content of a Label to a Binding Expression AND a static value?

Is there a way to set a Label's Content property to both a Binding Expression AND a static string value? I want to be able to display something like this:

"Current Value: [Value From Binding]"

I was thinking something like this would work, but apparently it doesn't:

<Label Content="Current Value: {Binding ElementName=SomeTextBox, Path=Content}"/>

Thanks in advance!

Upvotes: 0

Views: 259

Answers (1)

John Myczek
John Myczek

Reputation: 12256

If you are using .NET 3.5 SP1, you can use the ContentStringFormat:

<Label Content="{Binding ElementName=SomeTextBox, Path=Content}" ContentStringFormat="Current Value: {0}" />

Upvotes: 5

Related Questions