Skip to content

Enable dark mode for TreeView and ListView mouse tooltips - #14889

Open
LeafShi1 wants to merge 1 commit into
dotnet:mainfrom
LeafShi1:Fix_14878_TreeView_and_ListView_mouse_tooltips_color_issue
Open

Enable dark mode for TreeView and ListView mouse tooltips#14889
LeafShi1 wants to merge 1 commit into
dotnet:mainfrom
LeafShi1:Fix_14878_TreeView_and_ListView_mouse_tooltips_color_issue

Conversation

@LeafShi1

@LeafShi1 LeafShi1 commented Aug 13, 2026

Copy link
Copy Markdown
Member

Fixes #14878

Root Cause

TreeView and ListView use native tooltip windows for mouse-hover tooltips. Dark mode was applied to the controls themselves and to managed keyboard tooltips, but not to these native tooltip windows.

Proposed changes

  • Retrieve the native tooltip handles using TVM_GETTOOLTIPS and LVM_GETTOOLTIPS, then apply the DarkMode_Explorer theme when dark mode is enabled for the control.

Customer Impact

  • Applications using TreeView or ListView in dark mode now provide visually consistent tooltips.

Regression?

  • No

Risk

  • Minimal

Screenshots

Before

With SystemColorMode.Dark enabled, mouse-hover tooltips for TreeView and ListView were rendered using the light theme. Keyboard tooltips were already rendered in dark mode.

Image

After

Mouse-hover and keyboard tooltips for TreeView and ListView are consistently rendered in dark mode when SystemColorMode.Dark is enabled.

image image

Test methodology

  • Manually

Test environment(s)

  • .net 11.0.0-rc.1.26411.119
Microsoft Reviewers: Open in CodeFlow

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables dark-mode theming for the native (mouse-hover) tooltip windows used by TreeView and ListView, aligning their appearance with existing dark-mode support for the controls and managed keyboard tooltips.

Changes:

  • TreeView: retrieves the native tooltip HWND via TVM_GETTOOLTIPS and applies the DarkMode_Explorer theme when dark mode is enabled.
  • ListView: retrieves the native tooltip HWND via LVM_GETTOOLTIPS and applies the DarkMode_Explorer theme when dark mode is enabled.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/System.Windows.Forms/System/Windows/Forms/Controls/TreeView/TreeView.cs Applies dark-mode theme to the TreeView native tooltip handle during handle creation.
src/System.Windows.Forms/System/Windows/Forms/Controls/ListView/ListView.cs Applies dark-mode theme to the ListView native tooltip handle during on-demand dark mode application.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +2026 to +2038
if (Application.IsDarkModeEnabled && DarkModeRequestState is true)
{
HWND toolTipHandle = (HWND)PInvokeCore.SendMessage(
this,
PInvoke.TVM_GETTOOLTIPS,
(WPARAM)0,
(LPARAM)0);

PInvoke.SetWindowTheme(
toolTipHandle,
$"{DarkModeIdentifier}_{ExplorerThemeIdentifier}",
null);
}
Comment on lines +4696 to +4707
// Apply dark mode theme to the ListView Tooltip
HWND toolTipHandle = (HWND)PInvokeCore.SendMessage(
this,
PInvoke.LVM_GETTOOLTIPS,
(WPARAM)0,
(LPARAM)0);

PInvoke.SetWindowTheme(
toolTipHandle,
$"{DarkModeIdentifier}_{ExplorerThemeIdentifier}",
null);

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.

[Dark Mode] The mouse ToolTip is not in dark mode for TreeView & ListView controls after enabled SystemColorMode.Dark

2 participants