我需要将自定义依赖项属性绑定到控件内的Image元素。
现在Label
的{{1}}与Foreground
绑定得非常好,但TextForeground
内的GeometryDrawing
绑定得很好(图片保持透明)。< / p>
有什么问题?
Image
答案 0 :(得分:3)
GeometryDrawing
没有TextForeground
属性。您正在引用Self,即GeometryDrawing
。如果您尝试从其他控件中抓取RelativeSource
,请更改TextForeground
。
<GeometryDrawing.Pen>
<Pen Brush="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=TextForeground}" Thickness="1"/>
</GeometryDrawing.Pen>
答案 1 :(得分:3)
<UserControl x:Name="MyStopControl" >
...
<Pen Brush="{Binding ElementName=MyStopControl, Path=TextForeground}"/>
...
</UserControl>