Fix ToolBar overflow button background not inheriting from ToolBar#4028
Open
Fix ToolBar overflow button background not inheriting from ToolBar#4028
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3694
When a user sets a custom
Backgroundon aToolBar, the overflow button (the "..." toggle button that appears when items overflow) did not inherit that background — it stayed hardcoded toMaterialDesign.Brush.ToolBar.Background, creating a visual mismatch.Changes
MaterialDesignTheme.ToolBar.xaml:MaterialDesignToolBarVerticalOverflowButtonStyleandMaterialDesignToolBarHorizontalOverflowButtonStylenow bind theirBackgroundto the ancestorToolBar'sBackgroundusing aRelativeSourcebinding instead of hardcoding the theme resourceToolBarSubMenuBorder) now usesTemplateBinding Backgroundto inherit the ToolBar's backgroundBackgroundsetter in the vertical orientation trigger that was resetting to the static resourceToolBarTests.cs:ToolBar_OverflowButton_InheritsCustomBackground) that verifies the overflow button inherits a custom background set on the ToolBarDefault behavior preserved
When no custom
Backgroundis set, the ToolBar's ownBackgrounddefaults toMaterialDesign.Brush.ToolBar.Background, so the overflow button inherits the same value as before — no visual change for existing users.The
HighContrastDataTrigger on both overflow button styles still overrides the background when high contrast mode is active.