WPF How do you set the Background color of a context menu so that it overrides the background color of a grid -
WPF How do you set the Background color of a context menu so that it overrides the background color of a grid -
i have style set follows:
<style targettype="grid" > <setter property="control.background"> <setter.value> <solidcolorbrush> <solidcolorbrush.color> <color a="255" r="51" g="50" b="51"/> </solidcolorbrush.color> </solidcolorbrush> </setter.value> </setter> </style>
i have style set context menu looks this:
<style x:key="contextmenuitem" targettype="{x:type menuitem}" basedon="{staticresource {x:type menuitem}}" > <setter property="background" value="pink" /> </style>
the context menu appears on stackpanel nested within grid. don't understand why background context menu darkgray outlined in pink. way context menu display disable style grid. i've tried can think of including creating controltemplate contextmenu.
why grid background color affecting menu background color , how on earth create knock off?
with
<style targettype="grid" >
you defining style all grid
controls in application (if have defined style in app.xaml) or window (if have defined style in window's resources). or if have defined style using <grid.style>
, apply grid
s in visual tree below styled grid
.
since default menuitem
command template contains grid
control, styled other grid
s.
in order avoid that, should improve use
<style x:key="mygridstyle" targettype="grid" >
and utilize style="{staticresource mygridstyle}"
grid
s want style particular color.
wpf
Comments
Post a Comment