How to change the border color of a GeometryDrawing in wpf

645 Views Asked by At

I have some WPF code binding a block to a color as follows:

    <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>

Now I want to bind the border (or Pen property) to another field, such as Element.BorderColor. How should that be done?

Thanks

1

There are 1 best solutions below

0
On

You can use the ElementName binding to bind to properties in other UI elements in your window

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