wpf - binding stringformat on label using string literal
Label.Content
is object so you can't use Binding.StringFormat
there as the binding's target type must be string
in order for it to work.
Two work arounds are: use TextBlock
instead of Label
and bind the Text
property.
Use Label.ContentStringFormat i.e.
<Label ContentStringFormat="Current Value {0} of 10" Content={Binding ...} />
You only need to escape the string
with {}
if your first character is a {
For the ToolTip, you can check out WPF binding with StringFormat doesn't work on ToolTips.
As far as the StringFormat you specified above, you have to escape your string.
StringFormat="{}Current Value {0} of 10"
Here are a bunch of StringFormat examples.http://blogs.msdn.com/b/llobo/archive/2008/05/19/wpf-3-5-sp1-feature-stringformat.aspx