Answer the question
In order to leave comments, you need to log in
How to bind the data of the Label element?
I'm trying to pass Text data from Content to a TextBlock in a ControlTemplate. But something doesn't work. What did I miss here?
<Style TargetType="{x:Type Label}" x:Key="Label2">
<Setter Property="Content" Value="{Binding Text}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border Margin="2"
HorizontalAlignment="Left"
Background="DarkCyan"
BorderBrush="LightCyan"
BorderThickness="1"
CornerRadius="3">
<TextBlock Margin="0"
Padding="5"
FontSize="13"
FontWeight="Medium"
Foreground="LightCyan"
Text="{Binding Text}"
TextAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question