-
I was following the explanation in the official docs and defined: <Application.Resources>
<ResourceDictionary>
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="TextContrastBack_Brush">DimGray</SolidColorBrush>
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<SolidColorBrush x:Key="TextContrastBack_Brush">White</SolidColorBrush>
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
</Application.Resources> in my <TextBox>
<ToolTip.Tip>
<StackPanel>
<StackPanel.Styles>
<Style Selector="Run">
<Setter Property="Background" Value="{StaticResource TextContrastBack_Brush}" />
</StackPanel.Styles>
</StackPanel>
</ToolTip.Tip>
</TextBox> However I get an exception at runtime saying that key However if I simply define the resource with the same key outside of Am I missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Statically, there is no Dark or Light theme during app initialization and styles processing. If your theme dictionary had "Default" key - it would be used, though. But better practice is to use DynamicResource for anything like this, what can be changed in runtime. |
Beta Was this translation helpful? Give feedback.
Statically, there is no Dark or Light theme during app initialization and styles processing. If your theme dictionary had "Default" key - it would be used, though.
But better practice is to use DynamicResource for anything like this, what can be changed in runtime.