首页 > 解决方案 > 将值从内部样式绑定到其外部样式

问题描述

我有Pivot风格。在这种Pivot风格中,我有这种PivotHeaderItem风格。现在我想将 的前景值绑定PivotHeaderItem到 的背景值Pivot

这是我的代码的结构。由于 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>

标签: xamluwpuwp-xaml

解决方案


推荐阅读