wpfui icon indicating copy to clipboard operation
wpfui copied to clipboard

Exception thrown when i change button appearance to Primary

Open DDarknessOne opened this issue 2 years ago • 5 comments

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

exc

OS version

Windows 11 22H2

.NET version

.NET 7.0

WPF-UI NuGet version

3.0.0 preview 8

Additional context

No response

DDarknessOne avatar Oct 22 '23 20:10 DDarknessOne

Ok, the wierd thing is every control throw the same exception what needs the accent color.

DDarknessOne avatar Oct 22 '23 21:10 DDarknessOne

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>

iltan987 avatar Oct 23 '23 19:10 iltan987

@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.

iltan987 avatar Oct 25 '23 08:10 iltan987

NuGet\Install-Package WPF-UI -Version 3.0.0-preview.7

mq2151189 avatar Oct 26 '23 02:10 mq2151189

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

Yuval-pa avatar Oct 28 '23 15:10 Yuval-pa