Skip to content

Fix ToolBar overflow button background not inheriting from ToolBar#4028

Open
Keboo wants to merge 1 commit intomasterfrom
fix/toolbar-overflow-button-background
Open

Fix ToolBar overflow button background not inheriting from ToolBar#4028
Keboo wants to merge 1 commit intomasterfrom
fix/toolbar-overflow-button-background

Conversation

@Keboo
Copy link
Copy Markdown
Member

@Keboo Keboo commented Mar 31, 2026

Summary

Fixes #3694

When a user sets a custom Background on a ToolBar, the overflow button (the "..." toggle button that appears when items overflow) did not inherit that background — it stayed hardcoded to MaterialDesign.Brush.ToolBar.Background, creating a visual mismatch.

Changes

MaterialDesignTheme.ToolBar.xaml:

  • Both MaterialDesignToolBarVerticalOverflowButtonStyle and MaterialDesignToolBarHorizontalOverflowButtonStyle now bind their Background to the ancestor ToolBar's Background using a RelativeSource binding instead of hardcoding the theme resource
  • The overflow popup border (ToolBarSubMenuBorder) now uses TemplateBinding Background to inherit the ToolBar's background
  • Removed the redundant Background setter in the vertical orientation trigger that was resetting to the static resource

ToolBarTests.cs:

  • Added a UI test (ToolBar_OverflowButton_InheritsCustomBackground) that verifies the overflow button inherits a custom background set on the ToolBar

Default behavior preserved

When no custom Background is set, the ToolBar's own Background defaults to MaterialDesign.Brush.ToolBar.Background, so the overflow button inherits the same value as before — no visual change for existing users.

The HighContrast DataTrigger on both overflow button styles still overrides the background when high contrast mode is active.

Change the overflow button styles to bind their Background to the
ancestor ToolBar's Background instead of hardcoding the theme resource.
This ensures the overflow button matches when a custom Background is
set on the ToolBar.

Changes:
- Both vertical and horizontal overflow button styles now use a
  RelativeSource binding to the parent ToolBar's Background
- Overflow popup border uses TemplateBinding to inherit Background
- Removed redundant Background reset in the vertical orientation trigger

Fixes #3694

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

ToolBar Overflow Button background

1 participant