【问题标题】:How to change the border color of a GeometryDrawing in wpf如何在 wpf 中更改 GeometryDrawing 的边框颜色
【发布时间】:2023-03-04 01:20:01
【问题描述】:

我有一些 WPF 代码将块绑定到颜色,如下所示:

    <GeometryDrawing>
        <GeometryDrawing.Brush>
            <LinearGradientBrush>
                <LinearGradientBrush.GradientStops>
                    <GradientStop Offset="0.00" Color="{Binding Path=Element.Color}"/>
                    <GradientStop Offset="1.00" Color="{Binding Path=Element.Color}"/>
                </LinearGradientBrush.GradientStops>
            </LinearGradientBrush>
        </GeometryDrawing.Brush>
    </GeometryDrawing>

现在我想将边框(或 Pen 属性)绑定到另一个字段,例如 Element.BorderColor。应该怎么做?

谢谢

【问题讨论】:

    标签: wpf geometrydrawing


    【解决方案1】:

    您可以使用 ElementName 绑定来绑定到窗口中其他 UI 元素的属性

    <GradientStop Offset="0.00" Color="{Binding ElementName=MyElement Path=TheColor}"/>
    

    【讨论】:

      猜你喜欢
      • 2015-02-06
      • 1970-01-01
      • 1970-01-01
      • 2010-09-09
      • 1970-01-01
      • 2020-01-12
      • 2013-02-18
      • 1970-01-01
      • 2017-12-02
      相关资源
      最近更新 更多