user342552
user342552

Reputation:

Change styles of Menu inside toolbar

I have toolbar with buttons and a menu. The menu item looks odd between the buttons. It has a white background and border. How to make it look exactly like the buttons. I tried to set the menu item background to Transparent but it doesn't work.

 <ToolBar>   
    <ToolBar.Background>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
            <LinearGradientBrush.GradientStops>
                <GradientStop Offset="0" Color="#d8dcdd"/>
                <GradientStop Offset="0.5" Color="#e0e7f2"/>
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
    </ToolBar.Background>    
    <Button>
         <Button.Content>
            <Image   Source="../Resources/button1.png"></Image>
        </Button.Content>
    </Button>
    <Button>
         <Button.Content>
            <Image   Source="../Resources/button2.png"></Image>
        </Button.Content>
    </Button>

    <MenuItem>
          <MenuItem.Header>                        
              <Image  Source="../Resources/icon.png"></Image>
          </MenuItem.Header>
        <MenuItem Header="Command 1"/>
        <MenuItem Header="Command 2"/>
    </MenuItem>
</ToolBar>

Any ideas?

Upvotes: 1

Views: 891

Answers (1)

user342552
user342552

Reputation:

I found it:

<ToolBar.Resources>
    <Style x:Key="{x:Static ToolBar.MenuStyleKey}" TargetType="Menu">
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="Background" Value="Transparent" />
    </Style>
</ToolBar.Resources>

Upvotes: 2

Related Questions