2016-12-01 42 views
0

当我悬停其他元素(如某些文本)时,我想更改任何Path的颜色的颜色。在同一层次结构高度上绑定来自其他元素的FontColor

这两个元素都在同一个层次高度。它们被放置在WrapPanel内。

<WrapPanel> 
    <Path Data="{StaticResource Email}" Fill="{Binding ??}"/> 
    <TextBlock>Einstellungen</TextBlock> 
</WrapPanel> 

如何我可以PathFill属性绑定到TextBlockForeground房产吗?有没有可能不使用x:Name

+0

为什么你不想使用'Name'? – Markinson

+0

@Derp因为我有大约20个不同的按钮。 – MyNewName

回答

0
<WrapPanel> 
     <Rectangle Width="20" Height="20" Fill="{Binding Tag,RelativeSource={RelativeSource Mode=FindAncestor,   
AncestorType={x:Type WrapPanel}}}"/> 
     <TextBlock Foreground="{Binding RelativeSource={RelativeSource Mode=FindAncestor,   
AncestorType={x:Type WrapPanel}}, Path=Tag,Mode=OneWayToSource}">Sample</TextBlock> 
    </WrapPanel> 
相关问题