Home > Enterprise >  Add a resource reference in XAML
Add a resource reference in XAML

Time:09-21

Is it possible in XAML to add a reference to resource? For example I have <Color x:Key="LightRed">#e24c3f</Color> and I need to have something like <Color x:Key="ErrorColor">*LightRed*</Color>.

CodePudding user response:

No, a Color resource cannot reference another Color resource if that's what you are asking.

As suggested by @Nawed Nabi Zada, you may define a brush that uses any color resource though:

<SolidColorBrush x:Key="ErrorBrush" Color="{StaticResource LightRed}"/>

You can easily change the colour of the brush in one place.

  • Related