DevExpress NavBar: Appearance has no effect
this question is fairly DevExpress-specific.
I use a NavBar control with the standard "SkinExplorerBarView" in a WinForms app, and would like to change the appearance of a selected navigation link.
I changed the background color of the control's "ItemPressed" and "ItemActive" appearances, as well as each single item's "Pressed" appearance, but none of these had the any effect on how the links look like when I click on them.
I also tried to set the control's LookAndFeel.UseDefaultLookAndFeel property to False, but that didn't help neither.
As proposed by Rusty, I then tried to implement the CustomDrawLink event, still without success. (Funnily, after having selected a link, it doesn't have the state "Selected" but "Pressed" instead, so I used that):
private void nbcNavigation_CustomDrawLink(object sender,
DevExpress.XtraNavBar.ViewInfo.CustomDrawNavBarElementEventArgs e)
{
if (e.ObjectInfo.State == DevExpress.Utils.Drawing.ObjectState.Pressed)
{
e.Appearance.BackColor = Color.FromArgb(192, 192, 255);
}
}
I found an example on using Cu开发者_StackOverflow社区stomDrawLink, but that does all the drawing by hand, which is much pain and overkill. I want the DevExpress "engine" to draw the link, just by using another BackColor.
The NavBar is a real pain to customize ... mostly because it is designed to give a common appearance for all navigation items (style police, not my idea). You should pick one of the skin styles that works best with your Gui (getting to know the skin/lookandfeel system is worth the time).
Then use the CustomDrawXXX events of the NavBar control for any custom painting needs :)
You could also use the DevX skin designer and create a skin just for the NavBar.
精彩评论