Search code examples
wpffillellipselineargradientbrushgradientstop

wpf bind ellipse gradientstop color to ivalueconverter


I have bind an ellipse to a checkbox and an iValueConverter (this works ... Fill(see below)).

 <Ellipse Name="ellLeftRoleEnabled" 
                 Fill="{Binding IsChecked, ElementName=btnRollLeftEnabled, Converter={StaticResource myColorConverter}}" 
                 Height="80" Canvas.Left="355" Stroke="#FF0C703E" Canvas.Top="440" Width="80"/>

But now, how can I use this for a LinearGradientBrush/GradientStop?

<Ellipse Name="ellLeftRoleMoving" Height="100" Canvas.Left="345" Stroke="Black" Canvas.Top="535" Width="100">
            <Ellipse.Fill>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="{?????} Offset="0"/>
                    <GradientStop Color="White" Offset="1"/>
                </LinearGradientBrush>
            </Ellipse.Fill>
        </Ellipse>

Please help. Thank You.


Solution

  • When using it for Color of a GradientStop Color you shouldn't return a Brush like the first converter but a Color. The rest is the same.