C
C#2mo ago
stigzler

WPF ContextMenu background color problems

I'm trying to implement a dark theme on a ContexMenu. I'm getting some strange artefacts around the icon column:
<!-- CONTEXTMENU STYLE -->
<Style x:Key="ContextMenu" TargetType="ContextMenu">
<Setter Property="Background" Value="{DynamicResource {x:Static vsshell:VsBrushes.WindowKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static vsshell:VsBrushes.WindowTextKey}}"/>
</Style>

<!-- MENU ITEM STYLE -->
<Style x:Key="MenuItem" TargetType="MenuItem">
<Setter Property="Background" Value="{DynamicResource {x:Static vsshell:VsBrushes.WindowKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static vsshell:VsBrushes.WindowTextKey}}"/>
</Style>

<StackPanel.ContextMenu>
<ContextMenu Style="{StaticResource ContextMenu}">
<MenuItem Header="Delete Gist" Background="{DynamicResource {x:Static vsshell:VsBrushes.WindowKey}}"
Style="{StaticResource MenuItem}">
<MenuItem.Icon>
<imaging:CrispImage Moniker="{x:Static catalog:KnownMonikers.DeleteListItem}"/>
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</StackPanel.ContextMenu>
<!-- CONTEXTMENU STYLE -->
<Style x:Key="ContextMenu" TargetType="ContextMenu">
<Setter Property="Background" Value="{DynamicResource {x:Static vsshell:VsBrushes.WindowKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static vsshell:VsBrushes.WindowTextKey}}"/>
</Style>

<!-- MENU ITEM STYLE -->
<Style x:Key="MenuItem" TargetType="MenuItem">
<Setter Property="Background" Value="{DynamicResource {x:Static vsshell:VsBrushes.WindowKey}}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static vsshell:VsBrushes.WindowTextKey}}"/>
</Style>

<StackPanel.ContextMenu>
<ContextMenu Style="{StaticResource ContextMenu}">
<MenuItem Header="Delete Gist" Background="{DynamicResource {x:Static vsshell:VsBrushes.WindowKey}}"
Style="{StaticResource MenuItem}">
<MenuItem.Icon>
<imaging:CrispImage Moniker="{x:Static catalog:KnownMonikers.DeleteListItem}"/>
</MenuItem.Icon>
</MenuItem>
</ContextMenu>
</StackPanel.ContextMenu>
The details of templates etc baffles me a bit. Any suggestions?
No description
0 Replies
No replies yetBe the first to reply to this messageJoin