I
I
iki900092018-02-18 16:21:51
WPF
iki90009, 2018-02-18 16:21:51

How to create your own analogue of the SystemColors class?

Style is set via xaml

<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>

You need to make your own MyColors class to substitute
<Setter Property="Background" Value="{DynamicResource {x:Static MyColors.ControlTextBrushKey}}"/>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Yudakov, 2018-02-18
@AlexanderYudakov

<Window
        xmlns:local="clr-namespace:MyCompany.Wpf.Example" 
        Background="{x:Static local:MyColors.ControlTextBrush}">
</Window>

namespace MyCompany.Wpf.Example
{
    public static class MyColors
    {
        public static readonly Brush ControlTextBrush =
            new SolidColorBrush(Colors.Red);
    }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question