Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a StaticResource Brush's Color?

I have a brush as a Resource:

<Application.Resources>
    <SolidColorBrush x:Key="AppBrush" Color="#FFFFFF"/>
</Application.Resources>

and I want to use it's Color:

<... BackgroundColor="{StaticResource AppBrush.Color}"/>

But it isn't possible and I get a xaml corruption error. How can I do that?

or in other away how to use Brush's Color in another Color resource:

<Application.Resources>
    <Color x:Key="AppColor">#FFFFFF { here how to use AppBrush.Color?}</Color>
    <SolidColorBrush x:Key="AppBrush" Color="#FFFFFF"/>
</Application.Resources>
like image 877
user3129221 Avatar asked Dec 23 '13 13:12

user3129221


2 Answers

it's even easier:

BackgroundColor="{StaticResource AppBrush}"

or try this

<Application.Resources>
<Color x:Key="AppColor">#FFFFFF</Color>
<SolidColorBrush x:Key="AppBrush" Color="{StaticResource AppColor}"/
</Application.Resources>
like image 198
gomi42 Avatar answered Nov 02 '22 08:11

gomi42


Try this:

BackgroundColor="{Binding Color, Source={StaticResource AppBrush}}"

This will only work if AppBrush is a SolidColorBrush.

like image 31
Gusdor Avatar answered Nov 02 '22 09:11

Gusdor