views:

281

answers:

1

Hi all,

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 CustomDrawLink, 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.

A: 

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.

Rusty
Hi Rusty. I didn't manage yet to use that event appropriately. (Incorporated my code in my question)
chiccodoro
@chiccodoro Cool..let me know if I can help.
Rusty
@Rusty: Thanks. Performing the drawing "by hand" as mentioned in my update did it. I cannot vote up your answer because I already did that once, but then thought I should first try it out and undid the voting. Now it says: You already voted... If you slightly modify your answer voting should be unlocked again. ;-)
chiccodoro
Just glad you got the results you needed.
Rusty