I have Pivot
style. Within this Pivot
style I have the PivotHeaderItem
style. Now I want to bind the foreground value of the PivotHeaderItem
to the background value of the Pivot
.
- I have tried to
TemplateBinding
to outer style but it's not working. - I have tried to
Binding
ElementName
Path
to outer style but it's not working.
Here is the structure of my code. I have deleted many codes due to character limitation of StackOverflow.
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style x:Key="OfficeTabPivotStyle" TargetType="Pivot">
<Setter Property="Background" Value="{ThemeResource SystemControlBackgroundAccentBrush}"/>
....
<Setter Property="Template">
.....
.....
<Grid Margin="5,0,0,0" Background="{ThemeResource PivotHeaderBackground}">
<Grid.RenderTransform>
<CompositeTransform x:Name="HeaderOffsetTranslateTransform"/>
</Grid.RenderTransform>
<Grid.Resources>
<Style TargetType="PivotHeaderItem">
<Setter Property="Foreground" Value="{Bind the pivot background value}" />
....
....
</Style>
</Grid.Resources>
....
....
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>