Databinding the color of a RadialGradient brush in silverlight 3

后端 未结 2 1690
终归单人心
终归单人心 2021-01-24 05:58

I am trying to databind the color of a RadialGradientBrush in silverlight 3 to a property, but just can\'t seem to get it to work.

For example, in a sample test app all

相关标签:
2条回答
  • 2021-01-24 06:17

    Ok, I solved this problem by going one level higher and databinding the RadialGradientBrush itself.

            <Rectangle x:Name="testRectangle" Height="100" Width="100" 
                       Fill="{Binding TestRadialGradientBrush}"
                       DataContext="{Binding ElementName=HomePageUC}" >
                </Rectangle>
    

    The RadialGradientBrush in turn is instantiated with the GradientStops set to the colors I want in the code behind.

    0 讨论(0)
  • 2021-01-24 06:23

    Unfortunately, you cannot do that since Binding happens on FrameworkElement and every object that inherits it. GradientStop is not a FrameworkElement, which prevents you from binding its Color property.

    0 讨论(0)
提交回复
热议问题