如何改变一个控件 比如 一个 menu item 选中的颜色??使用WPF
请各位帮忙
我使用WPF 创建了一个Menu 里面放几个 Menu Item
我可以改变每个 item 的外观 比如颜色
但是使用鼠标 点击 或者 悬停在 这个item上 还是xp 的默认蓝色
所以想请教各位如何改变这个颜色
------解决方案--------------------
可以改菜单栏和工具栏的颜色
class MenuBarColor : ProfessionalColorTable
{
Color ManuBarCommonColor = Color.LightSteelBlue;
Color ManuCheckColor = Color.WhiteSmoke;
public MenuBarColor()
{
}
public override Color ButtonSelectedGradientEnd
{
get
{
return ManuBarCommonColor;
}
}
public override Color ButtonSelectedGradientBegin
{
get
{
return ManuBarCommonColor;
}
}
public override Color ButtonSelectedGradientMiddle
{
get
{
return ManuBarCommonColor;
}
}
public override Color MenuItemSelectedGradientBegin
{
get
{
return ManuBarCommonColor;
}
}
public override Color MenuItemSelectedGradientEnd
{
get
{
return ManuBarCommonColor;
}
}
public override Color ImageMarginGradientBegin
{
get
{
return Color.White;
}
}
public override Color ImageMarginGradientMiddle
{
get
{
return Color.Silver;
}
}
public override Color ImageMarginGradientEnd
{
get
{
return Color.Silver; ;
}
}
public override Color MenuItemPressedGradientBegin
{
get
{
return ManuCheckColor;
}
}
public override Color MenuItemPressedGradientMiddle
{
get
{
return ManuCheckColor;
}
}
public override Color MenuItemPressedGradientEnd
{
get
{
return ManuCheckColor;
}
}
public override Color ButtonPressedGradientBegin
{
get
{
return ManuBarCommonColor;
}
}
public override Color ButtonPressedGradientMiddle
{
get
{
return ManuBarCommonColor;
}
}
public override Color ButtonPressedGradientEnd
{
get
{
return ManuBarCommonColor;
}
}
public override Color MenuItemSelected
{
get
{
return ManuBarCommonColor;
}
}
}
internal class ToolStripRendererEx : ToolStripProfessionalRenderer
{
public ToolStripRendererEx()
: base(new MenuBarColor())
{
}
}
}