Reputation: 41088
I had the following XAML:
<Label>
<Underline Foreground="Blue">Foo</Underline>
</Label>
Now I would like to replace the text "Foo" at runtime using a binding, but obviously I can't place a {..} binding in place of Foo here. What's the correct way to do this?
Upvotes: 1
Views: 1265
Reputation: 13491
I came across this,
<Label>
<Underline Foreground="Blue">
<Underline.Inlines>
<TextBlock Text="{Binding Text}"></TextBlock>
</Underline.Inlines>
</Underline>
</Label>
And in fact you can reduce that to this,
<Label>
<Underline Foreground="Blue">
<TextBlock Text="{Binding Text}"></TextBlock>
</Underline>
</Label>
Or you can do it like this,
<Label Name="label">
<TextBlock Name="textBlock" TextDecorations="Underline" Text="Test"/>
</Label>
So back to your underline with the text 'Foo' you were defining an inline.
http://msdn.microsoft.com/en-us/library/system.windows.documents.underline.aspx
It says this,
An inline-level flow content element which causes content to render with an underlined text decoration.
So it is a group of inlines, and takes the format of this,
<Underline>
Inlines
</Underline>
Upvotes: 4