wpfui icon indicating copy to clipboard operation
wpfui copied to clipboard

Light theme broken in last release

Open TheoCvg opened this issue 1 month ago • 4 comments

Describe the bug

Setting application theme using ApplicationThemeManager does not work as I expected. Works fine when using WPFUI 4.0.3 but not in 4.1.0

To Reproduce

I just copy pasted the code of the settings view from the WPFUI gallery

Expected behavior

A correct light theme

Screenshots

When first opening the app the light theme works fine: Image

Switching to dark theme works fine too: Image

But comming back to white theme does this : Image

OS version

windows 11

.NET version

.NET 8.0

WPF-UI NuGet version

4.1.0

Additional context

in app resources i used :

<Application.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ui:ThemesDictionary Theme="Light" />
            <ui:ControlsDictionary />
        </ResourceDictionary.MergedDictionaries>

        <helpers:EnumToBooleanConverter x:Key="EnumToBooleanConverter" />
        <helpers:ThemeToIndexConverter x:Key="ThemeToIndexConverter" />
        <helpers:PaneDisplayModeToIndexConverter x:Key="PaneDisplayModeToIndexConverter" />
    </ResourceDictionary>
</Application.Resources>

The settings viewmodel :

public partial class SettingsViewModel(INavigationService navigationService) : ViewModel
{
	private bool _isInitialized = false;

	[ObservableProperty]
	private string _appVersion = string.Empty;

	[ObservableProperty]
	private ApplicationTheme _currentApplicationTheme = ApplicationTheme.Unknown;

	[ObservableProperty]
	private NavigationViewPaneDisplayMode _currentApplicationNavigationStyle =
		NavigationViewPaneDisplayMode.Left;

	public override void OnNavigatedTo()
	{
		if (!_isInitialized)
		{
			InitializeViewModel();
		}
	}

	partial void OnCurrentApplicationThemeChanged(ApplicationTheme oldValue, ApplicationTheme newValue)
	{
		ApplicationThemeManager.Apply(newValue);
	}

	partial void OnCurrentApplicationNavigationStyleChanged(
		NavigationViewPaneDisplayMode oldValue,
		NavigationViewPaneDisplayMode newValue
	)
	{
		_ = navigationService.SetPaneDisplayMode(newValue);
	}

	private void InitializeViewModel()
	{
		CurrentApplicationTheme = ApplicationThemeManager.GetAppTheme();
		AppVersion = $"{GetAssemblyVersion()}";

		ApplicationThemeManager.Changed += OnThemeChanged;

		_isInitialized = true;
	}

	private void OnThemeChanged(ApplicationTheme currentApplicationTheme, Color systemAccent)
	{
		// Update the theme if it has been changed elsewhere than in the settings.
		if (CurrentApplicationTheme != currentApplicationTheme)
		{
			CurrentApplicationTheme = currentApplicationTheme;
		}
	}

	private static string GetAssemblyVersion()
	{
		return Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? string.Empty;
	}

}

TheoCvg avatar Dec 01 '25 22:12 TheoCvg

Hi @MoodieG , can you please information about version of WinUI you are using?

snigdha011997 avatar Oct 30 '25 15:10 snigdha011997

The reproducible sample I shared is using a simple console application. However, the actual application is using Blazor Hybrid with WPF.

MoodieG avatar Oct 30 '25 16:10 MoodieG

It does not crash on my configuration (Windows 10 22H2, WinUI 3 Desktop app as Admin (Manifest), Windows App SDK 1.7.250401001)

castorix avatar Oct 30 '25 17:10 castorix

Hi @MoodieG , the above information is not sufficient for us to reproduce the issue, we need minimal repro project and its related details to investigate further

snigdha011997 avatar Dec 12 '25 09:12 snigdha011997

Hey @snigdha011997 , my original post shares the csproj file along with the program and environment details. What other details can I share?

This bug is related to using Windows.UI.Input.Preview.Injection APIs. Let me know if this is the wrong repo to post this issue. I posted it here because I found other users post similar issues regarding that here.

MoodieG avatar Dec 12 '25 18:12 MoodieG

@MoodieG Since it didn't reproduced by others, can you please attach a complete repro project as zip?

ayushjai19 avatar Dec 18 '25 15:12 ayushjai19