Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 116125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:07:42+00:00 2026-05-11T03:07:42+00:00

Does anyone know how to change the brush for a menu’s background? This sounds

  • 0

Does anyone know how to change the brush for a menu’s background? This sounds simple, but I don’t see any obvious way to do this. You’d think that the Background property would change it, but it doesn’t.

Here’s what my menu looks like (notice the default white background):

Example Code:

<Window x:Class='WpfApplication1.Window1' xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' Title='Window1' Height='300' Width='300'>  <Window.Resources>     <SolidColorBrush x:Key='menuItemBrush'                      Color='#FF505050' /> </Window.Resources>  <Grid x:Name='mainGrid'       Background='#FF252525'>      <Menu x:Name='mainMenu'           Background='{DynamicResource menuItemBrush}'           Grid.ColumnSpan='2'           VerticalAlignment='Top'>          <MenuItem x:Name='fileMenu'                   Background='{DynamicResource menuItemBrush}'                   Foreground='White'                   Header='File'>              <MenuItem x:Name='fileOpenMenuItem'                       Background='{DynamicResource menuItemBrush}'                       Foreground='White'                       Header='Open...' />              <MenuItem x:Name='fileSaveMenuItem'                       Background='{DynamicResource menuItemBrush}'                       Foreground='White'                       Header='Save' />              <MenuItem x:Name='fileSaveAsMenuItem'                       Background='{DynamicResource menuItemBrush}'                       Foreground='White'                       Header='Save As...' />              <Separator Style='{DynamicResource menuItemSeperator}' />              <MenuItem x:Name='fileExitMenuItem'                       Background='{DynamicResource menuItemBrush}'                       Foreground='White'                       Header='Exit' />         </MenuItem>     </Menu> </Grid> 

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:07:43+00:00Added an answer on May 11, 2026 at 3:07 am

    I’d suggest using a tool called kaxaml for writing styles. It includes several code snippets, a color picker and a nice way to instantly see what changes in the xaml code does. Here is a full menu style for what you are trying to do. Just change the brush colors at the top to suit to your needs.

    <Page   xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation'   xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml'>   <Page.Resources>    <!--**************************     * STYLE: MenuItem     ************************** -->   <SolidColorBrush x:Key='HighlightedBackgroundBrush' Color='#FF797878' />   <SolidColorBrush x:Key='MenuBackgroundBrush' Color='#FF505050' />   <SolidColorBrush x:Key='NormalBorderBrush' Color='#FFFFFFFF' />   <SolidColorBrush x:Key='SolidMenuFontBrush' Color='#FFFFFFFF' />   <SolidColorBrush x:Key='HighlightedText' Color='#FFFFFFFF' />   <Style x:Key='{x:Type Menu}' TargetType='{x:Type Menu}'>     <Setter Property='OverridesDefaultStyle' Value='True'/>     <Setter Property='SnapsToDevicePixels' Value='True'/>     <Setter Property='Height' Value='25'/>     <Setter Property='Foreground' Value='{StaticResource SolidMenuFontBrush}'/>     <Setter Property='Template'>       <Setter.Value>         <ControlTemplate TargetType='{x:Type Menu}'>           <Border             Background='{StaticResource MenuBackgroundBrush}'             BorderBrush='{StaticResource MenuBackgroundBrush}'             BorderThickness='1'>             <StackPanel ClipToBounds='True' Orientation='Horizontal' IsItemsHost='True'/>           </Border>         </ControlTemplate>       </Setter.Value>     </Setter>   </Style>   <Style x:Key='{x:Type MenuItem}' TargetType='{x:Type MenuItem}'>     <Setter Property='Template'>       <Setter.Value>         <ControlTemplate TargetType='{x:Type MenuItem}'>           <Border x:Name='Border'                   Background='{TemplateBinding Background}'                   BorderBrush='{TemplateBinding BorderBrush}'                   BorderThickness='1'>             <Grid>               <Grid.ColumnDefinitions>                 <ColumnDefinition x:Name='Col0' MinWidth='17' Width='Auto' SharedSizeGroup='MenuItemIconColumnGroup'/>                 <ColumnDefinition Width='Auto' SharedSizeGroup='MenuTextColumnGroup'/>                 <ColumnDefinition Width='Auto' SharedSizeGroup='MenuItemIGTColumnGroup'/>                 <ColumnDefinition x:Name='Col3' Width='14'/>               </Grid.ColumnDefinitions>                <!-- ContentPresenter to show an Icon if needed -->               <ContentPresenter Grid.Column='0' Margin='4,0,6,0' x:Name='Icon' VerticalAlignment='Center' ContentSource='Icon'/>                <!-- Glyph is a checkmark if needed for a checkable menu -->               <Grid Grid.Column='0' Visibility='Hidden' Margin='4,0,6,0' x:Name='GlyphPanel' VerticalAlignment='Center'>                 <Path x:Name='GlyphPanelpath' VerticalAlignment='Center' Fill='{TemplateBinding Foreground}' Data='M0,2 L0,4.8 L2.5,7.4 L7.1,2.8 L7.1,0 L2.5,4.6 z' FlowDirection='LeftToRight'/>               </Grid>                <!-- Content for the menu text etc -->               <ContentPresenter Grid.Column='1'                                 Margin='{TemplateBinding Padding}'                                 x:Name='HeaderHost'                                 RecognizesAccessKey='True'                                 ContentSource='Header'/>                <!-- Content for the menu IGT -->               <ContentPresenter Grid.Column='2'                                 Margin='8,1,8,1'                                 x:Name='IGTHost'                                 ContentSource='InputGestureText'                                 VerticalAlignment='Center'/>                <!-- Arrow drawn path which points to the next level of the menu -->               <Grid Grid.Column='3' Margin='4,0,6,0' x:Name='ArrowPanel' VerticalAlignment='Center'>                 <Path x:Name='ArrowPanelPath' HorizontalAlignment='Right' VerticalAlignment='Center' Fill='{TemplateBinding Foreground}' Data='M0,0 L0,8 L4,4 z'/>               </Grid>                <!-- The Popup is the body of the menu which expands down or across depending on the level of the item -->               <Popup IsOpen='{Binding Path=IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}' Placement='Right' x:Name='SubMenuPopup' Focusable='false' PopupAnimation='{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}'>                 <Border x:Name='SubMenuBorder' BorderBrush='{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Menu}}}' BorderThickness='1' Padding='2,2,2,2'>                   <Grid x:Name='SubMenu' Grid.IsSharedSizeScope='True'>                     <!-- StackPanel holds children of the menu. This is set by IsItemsHost=True -->                     <StackPanel IsItemsHost='True' KeyboardNavigation.DirectionalNavigation='Cycle'/>                   </Grid>                 </Border>               </Popup>             </Grid>           </Border>            <!-- These triggers re-configure the four arrangements of MenuItem to show different levels of menu via Role -->           <ControlTemplate.Triggers>             <!-- Role = TopLevelHeader : this is the root menu item in a menu; the Popup expands down -->             <Trigger Property='Role' Value='TopLevelHeader'>               <Setter Property='Padding' Value='6,1,6,1'/>               <Setter Property='Placement' Value='Bottom' TargetName='SubMenuPopup'/>               <Setter Property='MinWidth' Value='0' TargetName='Col0'/>               <Setter Property='Width' Value='Auto' TargetName='Col3'/>               <Setter Property='Visibility' Value='Collapsed' TargetName='Icon'/>               <Setter Property='Visibility' Value='Collapsed' TargetName='GlyphPanel'/>               <Setter Property='Visibility' Value='Collapsed' TargetName='IGTHost'/>               <Setter Property='Visibility' Value='Collapsed' TargetName='ArrowPanel'/>             </Trigger>              <!-- Role = TopLevelItem :  this is a child menu item from the top level without any child items-->             <Trigger Property='Role' Value='TopLevelItem'>               <Setter Property='Padding' Value='6,1,6,1'/>               <Setter Property='Visibility' Value='Collapsed' TargetName='ArrowPanel'/>             </Trigger>              <!-- Role = SubMenuHeader : this is a child menu item which does not have children -->             <Trigger Property='Role' Value='SubmenuHeader'>               <Setter Property='DockPanel.Dock' Value='Top'/>               <Setter Property='Padding' Value='0,2,0,2'/>             </Trigger>              <!-- Role = SubMenuItem : this is a child menu item which has children-->             <Trigger Property='Role' Value='SubmenuItem'>               <Setter Property='DockPanel.Dock' Value='Top'/>               <Setter Property='Padding' Value='0,2,0,2'/>               <Setter Property='Visibility' Value='Collapsed' TargetName='ArrowPanel'/>             </Trigger>             <Trigger Property='IsSuspendingPopupAnimation' Value='true'>               <Setter Property='PopupAnimation' Value='None' TargetName='SubMenuPopup'/>             </Trigger>              <!-- If no Icon is present the we collapse the Icon Content -->             <Trigger Property='Icon' Value='{x:Null}'>               <Setter Property='Visibility' Value='Collapsed' TargetName='Icon'/>             </Trigger>              <!-- The GlyphPanel contains the CheckMark -->             <Trigger Property='IsChecked' Value='true'>               <Setter Property='Visibility' Value='Visible' TargetName='GlyphPanel'/>               <Setter Property='Visibility' Value='Collapsed' TargetName='Icon'/>             </Trigger>              <!-- Using the system colors for the Menu Highlight and IsEnabled-->             <Trigger Property='IsHighlighted' Value='true'>               <Setter Property='Background' Value='{StaticResource HighlightedBackgroundBrush}' TargetName='Border'/>               <Setter Property='Foreground' Value='{StaticResource HighlightedText}'/>               <Setter Property='BorderBrush' Value='{StaticResource NormalBorderBrush}' TargetName='Border'/>             </Trigger>             <Trigger Property='IsHighlighted' Value='false'>               <Setter Property='Background' Value='{StaticResource MenuBackgroundBrush}' TargetName='Border'/>               <Setter Property='Foreground' Value='{StaticResource SolidMenuFontBrush}'/>               <Setter Property='BorderBrush' Value='{StaticResource MenuBackgroundBrush}' TargetName='Border'/>             </Trigger>             <Trigger Property='IsEnabled' Value='false'>               <Setter Property='Foreground' Value='LightGray'/>             </Trigger>           </ControlTemplate.Triggers>         </ControlTemplate>       </Setter.Value>     </Setter>   </Style>   </Page.Resources> <Grid x:Name='mainGrid'       Background='#FF252525'>      <Menu x:Name='mainMenu'           Grid.ColumnSpan='2'           VerticalAlignment='Top'>          <MenuItem x:Name='fileMenu'                   Header='File'>              <MenuItem x:Name='fileOpenMenuItem'                       Header='Open...' />              <MenuItem x:Name='fileSaveMenuItem'                       Header='Save' />              <MenuItem x:Name='fileSaveAsMenuItem'                       Background='{DynamicResource menuItemBrush}'                       Header='Save As...' />         </MenuItem>     </Menu>   </Grid> </Page> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 71k
  • Answers 72k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer You could set them all to be 'now' + id.… May 11, 2026 at 1:29 pm
  • added an answer WPF projects will - by default - generate an entry… May 11, 2026 at 1:29 pm
  • added an answer Here is the deal: in machine learning problems, you typically… May 11, 2026 at 1:29 pm

Related Questions

No related questions found

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.