I am new in WPF, so i am little lost with the "binding" and stuff like that.
I just created a controlTemplate of a custom Expander, here is my code:
<Style TargetType="{x:Type ToggleButton}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border Padding="{TemplateBinding Padding}">
<Grid SnapsToDevicePixels="False">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="6*"/>
</Grid.ColumnDefinitions>
<Border Grid.ColumnSpan="2" Name="bgHack" Background="#FFFFC000" />
<Image Grid.ColumnSpan="2" HorizontalAlignment="Center" Name="imageArrow" Source="Images/downRow.png" Stretch="None"/>
<Viewbox Grid.Column="0" Stretch="Uniform" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<!--HERE IS THE VALUE OF THE TEXT I WANT TO CHANGE IN EACH INSTANCE-->
<TextBlock Name="headerText" Foreground="White" FontFamily="/BundyPOS;component/Fonts/#HelveticaRounded" TextAlignment="Center" Margin="7">Artículos</TextBlock>
</Viewbox>
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="1" ContentStringFormat="{TemplateBinding ContentStringFormat}" HorizontalAlignment="Left" Margin="4,0,0,0" RecognizesAccessKey="True" SnapsToDevicePixels="True" VerticalAlignment="Center"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True"><!--WHEN CLICK IS RELEASED-->
<Setter Property="Source" TargetName="imageArrow" Value="Images/upRow.png"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="bgHack" Value="#3cb878"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
I am also able to instance this controlTemplate like this:
<Expander Name="articlesExpander" Template="{StaticResource ExpanderHeaderImage}">
<StackPanel>
<TextBox>This is a textbox</TextBox>
<Button>A button</Button>
</StackPanel>
</Expander>
How can i change the text value of the TextBlock located at the controlTemplate? I mean, i am going to create several instances of this controlTemplate and i need to change the text of the TextBlock in each one.