I have a custom class, "FavoriteColor" that has three properties, R, G and B. Now I want to draw a rectangle and fill it with these R, G and B values (using databinding). I tried the following snippet in my xaml, but gives me a compile time error.
<Rectangle Width="10" Height="10" Grid.Column="4">
<Rectangle.Fill>
<SolidColorBrush>
<SolidColorBrush.Color>
<Color R="{Binding Path=R}" />
<Color G="{Binding Path=G}" />
<Color B="{Binding Path=B}" />
</SolidColorBrush.Color>
</SolidColorBrush>
</Rectangle.Fill>
</Rectangle>
It says that the properties R, G and B of Color class are not dependency properties. I know that you can bind data only to dependency properties, but in this case, how do I bind my R, G and B with the rectangle's fill color.
Is there any other way other than by declaring one more property of type color and then initializing it when R, G and B are set? Also why the R, G and B of the color class are not dependency properties?