-
Notifications
You must be signed in to change notification settings - Fork 804
Open
Labels
Description
Describe the bug
When multiple tabs are open in a TabView and the application theme or system theme is changed (either manually or automatically), the application crashes with the following error:
System.ArgumentException: Value does not fall within the expected range.
here is my code for theme change
try
{
var currentTheme = (FrameworkElement)App.m_window.Content;
if (App.m_window.Content is FrameworkElement rootElement)
{
rootElement.RequestedTheme = param;
TitleBarHelper.UpdateTitleBar(param);
var ThemeSaved = await _settings.SaveSettings(AppConstants.Theme_Key, param.ToString());
if (ThemeSaved)
{
infoBar.Severity = InfoBarSeverity.Success;
infoBar.Title = "Theme Changed";
infoBar.Message = $"Theme has been changed to {param.ToString()}.";
infoBar.IsIconVisible = true;
infoBar.IsOpen = true;
await Task.CompletedTask;
}
}
}
catch (Exception ex)
{
infoBar.Severity = InfoBarSeverity.Error;
infoBar.Title = "Error";
infoBar.Message = $"An error occurred while changing the theme: {ex.Message}";
infoBar.IsIconVisible = true;
infoBar.IsOpen = true;
await Task.CompletedTask;
}
i have tried to iterating through the tabs farme and update there Theme still no luck.
Steps to reproduce the bug
- create a WinUI app
- implement TabView with settings page where you can change the theme to dark or light
- change the theme while multiple tabs are open
- now try to switch the tab it will throw an error
Expected behavior
No response
Screenshots
No response
NuGet package version
None
Windows version
No response
Additional context
No response
Reactions are currently unavailable