views:

998

answers:

3

I create popup menu like this.

<DockPanel.ContextMenu>
    <ContextMenu Background="#CD252220" Opacity="0.95" Foreground="LightGray" BorderBrush="DarkGray">
        <MenuItem Header="_Save Image..." x:Name="btSave" IsEnabled="False" Click="btSave_Click" Style="{StaticResource MyStyle}">
            <MenuItem.Icon>
                <Image Source="icons/save.png" Width="16" Height="16" Style="{StaticResource IconStyle}"/>
            </MenuItem.Icon>
        </MenuItem>
    </ContextMenu>
</DockPanel.ContextMenu>

Why left-side of this menu is WHITE????? It'll be a #CD252220 color or transparent, bun not white!!!!!! How to fix it? :)

http://itrash.ru/idb/40e872e71346dcf9bd58ba8aec0b2a17/omenu.png.html - menu screenshot

P.S. In XP it's OK. Menu is White only on Vista (don't have W7)

A: 

This might be helpful:

http://www.dev102.com/2008/06/20/how-to-create-a-wpf-custom-context-menu/

Yogesh
A: 

If you will declare a custom style for your context menu, This way it will be same for all OS.

viky
A: 

I find solution! You have to just set property OverridesDefaultStyle in Style-defenition section ;)

<Style x:Key="{x:Type ContextMenu}" TargetType="{x:Type ContextMenu}">
<Setter Property="OverridesDefaultStyle" Value="True"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContextMenu}">
<Border Background="#CD222120" CornerRadius="7, 7, 8, 8" BorderBrush="DarkGray" BorderThickness="2" Opacity="0.96">
<StackPanel ClipToBounds="True" Orientation="Vertical" IsItemsHost="True" Margin="5,4,5,4"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="{x:Static MenuItem.TopLevelItemTemplateKey}" TargetType="{x:Type MenuItem}">
<Border Name="Border" >
<Grid>
<ContentPresenter Margin="6,3,6,3" ContentSource="Header" RecognizesAccessKey="True" />
</Grid>
</Border>
</ControlTemplate>
NiCketT