Current filter:
                                You should refresh the page.
                                0
                                  • Can I create a new view style for the XtraNavBar?

                                You must  log in  or  register  to leave comments

                                1 Solution

                                0

                                This article explains how to create a custom view for the XtraNavBar.

                                The view is defined by the NavBarViewInfo class. That's the NoExpandButtonViewNavBarViewInfo class in our sample, which is a direct descendant of the XPExplorerBarNavBarViewInfo class.

                                For the sake of the example, we will hide the expand/collapse buttons from group headers by creating a custom NavBarView. Generally, if you need to hide these buttons in your NavBar control, you don't have to create a custom view; it's enough to set the ExplorerBarShowGroupButtons property to False.

                                To hide the expand/collapse buttons we've implemented the OpenCloseButton painter class (NoExpandButtonOpenCloseButtonObjectPainter). It does not draw anything, so there is no button.

                                A user can expand/collapse a group by clicking its header. The DoGroupClick method is overridden so as to ignore mouse clicks and prevent a group from being collapsed.

                                The NoExpandButtonViewInfoRegistrator class registers the custom NavBar view.

                                Here is the code to assign the custom view to a NavBar control:

                                	
                                [C#]
                                public class CustomNavBarControl :NavBarControl { protected override void RegisterAvailableNavBarViews() { base.RegisterAvailableNavBarViews(); AvailableNavBarViews.Add(new NoExpandButtonViewInfoRegistrator()); } protected override BaseViewInfoRegistrator GetExplorerView(ActiveLookAndFeelStyle activeStyle) { if (activeStyle != ActiveLookAndFeelStyle.Skin) return AvailableNavBarViews[NoExpandButtonViewInfoRegistrator.CustomViewName]; return base.GetExplorerView(activeStyle); } }

                                	
                                [VB.NET]
                                Public Class CustomNavBarControl Inherits NavBarControl Protected Overrides Sub RegisterAvailableNavBarViews() MyBase.RegisterAvailableNavBarViews() AvailableNavBarViews.Add(New NoExpandButtonViewInfoRegistrator()) End Sub Protected Overrides Function GetExplorerView(ByVal activeStyle As ActiveLookAndFeelStyle) As BaseViewInfoRegistrator If activeStyle IsNot ActiveLookAndFeelStyle.Skin Then Return AvailableNavBarViews(NoExpandButtonViewInfoRegistrator.CustomViewName) End If Return MyBase.GetExplorerView(activeStyle) End Function End Class


                                 
                                See Also:
                                A2701

                                You must  log in  or  register  to leave comments