Reputation: 1
i want to bind color from SolidColorBrush and define Color resource from that.
<SolidColorBrush x:Key="MyBrush" Color="#FFF3F3F3"/>
<Color x:Key="MyColor" {how i bind brush color here?} />
or just i want to use the color in somewhere like in a ColorAnimation:
<SolidColorBrush x:Key="MyBrush" Color="#FFF3F3F3"/>
<Storyboard x:Key="MyStoryboard">
<ColorAnimation To="{Binding Color, Source={StaticResource MyBrush}}" Duration="0:0:1"
.
.
.
/>
</Storyboard>
i have this error:
'Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception.'
Upvotes: 0
Views: 589
Reputation: 128013
You usually do it the other way round:
<Color x:Key="MyColor">#FFF3F3F3</Color>
<SolidColorBrush x:Key="MyBrush" Color="{StaticResource MyColor}"/>
If you only have the SolidColorBrush and want to reuse its Color somewhere, you could always do it by a Binding like this:
Color="{Binding Color, Source={StaticResource MyBrush}}"
Upvotes: 1