Exception thrown when i change button appearance to Primary
Describe the bug
Exception: Cannot find resource named 'SystemAccentColorPrimary' thrown when i change button appearance to Primary.
To Reproduce
Create a new WPF .net 7 project, set up wpfui, add a <ui:Button Appearance="Primary"/> to the main grid, run your project.
Expected behavior
I expected that my button will actually change it's appearance to primary.
Screenshots
OS version
Windows 11 22H2
.NET version
.NET 7.0
WPF-UI NuGet version
3.0.0 preview 8
Additional context
No response
Ok, the wierd thing is every control throw the same exception what needs the accent color.
I am having the same problem with PasswordBox. When I clicked it, this exception thrown.
<ui:FluentWindow x:Class="Test.Views.Windows.LoginWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Title="LoginWindow" Width="325" Height="200" ui:Design.Background="{DynamicResource ApplicationBackgroundBrush}" ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}" ExtendsContentIntoTitleBar="True" Foreground="{DynamicResource TextFillColorPrimaryBrush}" ResizeMode="CanMinimize" WindowBackdropType="Mica" WindowCornerPreference="Round" WindowStartupLocation="CenterScreen" mc:Ignorable="d"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition /> </Grid.RowDefinitions> <ui:TitleBar x:Name="TitleBar" Title="Login" Grid.Row="0" ShowMaximize="False"> ui:TitleBar.Icon <ui:SymbolIcon Symbol="ShieldLock24" /> </ui:TitleBar.Icon> </ui:TitleBar> <StackPanel Grid.Row="1" Margin="15" VerticalAlignment="Center"> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition Height="10" /> <RowDefinition /> </Grid.RowDefinitions> <ui:PasswordBox Grid.Row="0" Icon="{ui:SymbolIcon Password24}" PlaceholderEnabled="True" PlaceholderText="Enter password" /> <ui:Button Grid.Row="2" Width="100" HorizontalAlignment="Center" Content="Ok" /> </Grid> </StackPanel> </Grid> </ui:FluentWindow>
@DDarknessOne I found the solution. You need to call Wpf.Ui.Appearance.ApplicationThemeManager.ApplySystemTheme function. It has a parameter called updateAccent. When you send true to it, everything getting fixed. The thing is, you need to apply it for each window.
NuGet\Install-Package WPF-UI -Version 3.0.0-preview.7
can confierm that this also aplies to .Net framework 4.8 but
@DDarknessOne I found the solution. You need to call Wpf.Ui.Appearance.ApplicationThemeManager.ApplySystemTheme function. It has a parameter called updateAccent. When you send true to it, everything getting fixed. The thing is, you need to apply it for each window.
fixed it for me