I'm assigning a text to Tag
property of the Button
but how can I use it from ResourceDictionary
.
My Button:
<Button Style="{StaticResource ControlBarButton}" Tag="-"/>
I want to use Tag property from content of the button My Resource Dictionary:
<Style TargetType="Button"
x:Key="ControlBarButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Button Width="35"
Content="I WANT TO USE `Tag` HERE">
</Button>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
CodePudding user response:
Use a TemplateBinding
in the template:
<Style TargetType="Button" x:Key="ControlBarButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Button Width="35"
Content="{TemplateBinding Tag}">
</Button>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>