xaml - 将值从内部样式绑定到其外部样式
问题描述
我有Pivot
风格。在这种Pivot
风格中,我有这种PivotHeaderItem
风格。现在我想将 的前景值绑定PivotHeaderItem
到 的背景值Pivot
。
- 我尝试过
TemplateBinding
外部风格,但它不起作用。 - 我尝试过
Binding
ElementName
Path
外部风格,但它不起作用。
这是我的代码的结构。由于 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>
解决方案
推荐阅读
- kubernetes - Kubernetes nginx-Ingress 反向代理一些路径
- c# - HttpWebRequest - 无法发送具有此动词类型的内容主体
- python - 如何避免 Scrapy url 被重定向
- mysql - MySQL - 试图过滤掉过去当前时间的日期和时间
- azure - DATEDIFF 溢出
- javascript - 选项:在 jquery 中选择也在隐藏选项中计数
- symfony - 如何为在 services.yaml 外部注册的服务提供参数
- ghostscript - Ghostscript PDF 字体在 Adobe Illustrator 中变成了框,在 Adobe Acrobat 中打开时它的输出很好
- neo4j - Neo4j 中的 apoc.cypher.mapParallel2 没有给出预期的结果
- python-3.x - Plotly dash - 动态显示 ndarray 图像