UWP, App.Xaml: override default brushes

If I need to override the color in the brush, I would set it in App.xaml as follows:

<Application.Resources> 

     ...

       <ResourceDictionary>
                <ResourceDictionary.ThemeDictionaries>
                    <ResourceDictionary x:Key="Light">
                        <SolidColorBrush x:Key="PivotHeaderForegroundUnselectedBrush" Color="#A7A9AC" />
                        <SolidColorBrush x:Key="PivotHeaderForegroundSelectedBrush" Color="Black" />
                    </ResourceDictionary>
                </ResourceDictionary.ThemeDictionaries>
            </ResourceDictionary>

         ...
</Application.Resources> 

The editor emphasizes <ResourceDictionary>, saying: "Each dictionary entry must have an associated key."

How to solve this?

+4
source share
2 answers

I solved the problem thanks to @Alan Yao - MSFT. Maybe you have more things there?I had something else written in ResourceDictionary. Having made the ResourceDictionaryparent element of everything inside Application.Resources, I solved the problem.

+3
source

ResourceDictionary should be placed in application resources:

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.ThemeDictionaries>
            <ResourceDictionary x:Key="Light">
                <SolidColorBrush x:Key="PivotHeaderForegroundUnselectedBrush" Color="#A7A9AC" />
                <SolidColorBrush x:Key="PivotHeaderForegroundSelectedBrush" Color="Black" />
            </ResourceDictionary>
        </ResourceDictionary.ThemeDictionaries>
    </ResourceDictionary>
</Application.Resources>
0
source

Source: https://habr.com/ru/post/1610008/


All Articles