Skip to content

Fix context menu background not following dark theme#131

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-context-menu-background-color
Draft

Fix context menu background not following dark theme#131
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-context-menu-background-color

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 13, 2026

WPF ContextMenu popups open via a PopupRoot with InheritanceBehavior.SkipAllNext, which severs propagation of iNKORE.UI.WPF.Modern's inheritable ThemeProperty. As a result, all context menus rendered light regardless of the application theme.

Changes

  • App.xaml.cs: Register a class-level handler for ContextMenu.OpenedEvent that explicitly calls ThemeManager.SetRequestedTheme with the current application theme on every context menu open. This injects the correct theme resources directly into the context menu's ResourceDictionary, covering both gear-button and right-click menus, and handles runtime theme switches.
EventManager.RegisterClassHandler(typeof(ContextMenu), ContextMenu.OpenedEvent,
    new RoutedEventHandler(OnContextMenuOpened));

private static void OnContextMenuOpened(object sender, RoutedEventArgs e)
{
    if (sender is ContextMenu contextMenu)
    {
        var elementTheme = ThemeManager.Current.ActualApplicationTheme == ApplicationTheme.Dark
            ? ElementTheme.Dark : ElementTheme.Light;
        ThemeManager.SetRequestedTheme(contextMenu, elementTheme);
    }
}

Copilot AI changed the title [WIP] Fix context menu background color not changing with theme Fix context menu background not following dark theme Apr 13, 2026
Copilot AI requested a review from Jack251970 April 13, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: 暗黑模式下从设置按钮打开的右键菜单文字背景不随主题而改变

2 participants