DevExpress NavBar:外观没有效果
这个问题是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自定义导航栏确实很痛苦……主要是因为它的设计目的是为所有导航项提供通用的外观(警察风格,不是我的想法)。您应该选择一种最适合您的 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.