-
Applying a ThemeDictionay fails in windows but it works in desktop and wasm. It seems that <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="KeyboardBackgroundDark" Color="#FF000000" />
<SolidColorBrush x:Key="KeyboardBackgroundLight" Color="#f2f2f2" />
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<StaticResource x:Key="KeyboardBackground" ResourceKey="KeyboardBackgroundLight" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<StaticResource x:Key="KeyboardBackground" ResourceKey="KeyboardBackgroundDark" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary> public sealed partial class KeyboardControl : Panel
{
public KeyboardControl()
{
LoadResources();
ActualThemeChanged += (s, e) => { ApplyThemedResources(); };
Loaded += (s, e) => { ApplyThemedResources(); };
}
private void LoadResources()
{
var resources = new ResourceDictionary() { Source = new Uri("ms-appx:///UnoKeyboard/Keyboard.xaml") };
Application.Current.Resources.MergedDictionaries.Add(resources);
}
private void ApplyThemedResources()
{
Background = (Brush)Application.Current.Resources["KeyboardBackground"];
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
@mcNets Indeed, the name of the helper is a bit confusing, as it actually only changes the theme of the root element of the application: In case of WinUI, it is not possible to change the |
Beta Was this translation helpful? Give feedback.
@MartinZikmund It seems something related to WinUI, so I opened a discussion there.
microsoft/microsoft-ui-xaml#9943