DevExpress NavBar:外观没有效果

发布于 2024-09-02 14:34:39 字数 958 浏览 12 评论 0原文

这个问题是 DevExpress 特定的。

我在 WinForms 应用程序中使用带有标准“SkinExplorerBarView”的 NavBar 控件,并且想要更改所选导航链接的外观

我更改了控件的“ItemPressed”和“ItemActive”外观的背景颜色,以及每个单个项目的“Pressed”外观,但是这些都不会对我单击链接时的链接外观产生任何影响。

我还尝试将控件的 LookAndFeel.UseDefaultLookAndFeel 属性设置为 False,但这也没有帮助。

按照 Rusty 的建议,我随后尝试实现 CustomDrawLink 事件,但仍然没有成功。 (有趣的是,选择链接后,它没有状态“已选择”而是“已按下”,所以我使用了它):

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);
    }
}

我发现 使用 CustomDrawLink 的示例,但是所有绘图都是手工完成的,这是非常痛苦和矫枉过正的。我希望 DevExpress“引擎”只需使用另一个 BackColor 即可绘制链接。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁的年少不轻狂 2024-09-09 14:34:39

自定义导航栏确实很痛苦……主要是因为它的设计目的是为所有导航项提供通用的外观(警察风格,不是我的想法)。您应该选择一种最适合您的 Gui 的皮肤样式(了解皮肤/外观和感觉系统是值得花时间的)。

然后使用 NavBar 控件的 CustomDrawXXX 事件来满足任何自定义绘制需求:)

您还可以使用 DevX 皮肤设计器并仅为 NavBar 创建一个皮肤。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文