Tomasz
Tomasz

Reputation: 2061

WPF SolidColorBrush bind to another StaticResource

I have question about SolidColorBrush.

I have Resource:

<SolidColorBrush x:Key="Accent3" Color="#0093DD"/>

And I would like to bind another resource to this one like this:

<SolidColorBrush x:Key="AccentColorBrush" Color="{Binding Source={StaticResource Accent3}}" />

Both of them are in same file, AccentColorBrush is below Accent3.

How should I do that?

Upvotes: 0

Views: 218

Answers (1)

Luca Perotti
Luca Perotti

Reputation: 196

You can create a color and then bind it to both your colorbrush...something like this:

<Color x:Key="YourColor">#0093DD</Color>


<SolidColorBrush x:Key="Accent3" Color="{StaticResource YourColor}"/>
<SolidColorBrush x:Key="AccentColorBrush" Color="{StaticResource YourColor}" />

Upvotes: 2

Related Questions