Question

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>
Was it helpful?

Solution 2

Try this:

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

This will only work if AppBrush is a SolidColorBrush.

OTHER TIPS

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top