Current filter:
                                You should refresh the page.

                                Custom XtraNavBar view: XPExplorer view without expand/collapse buttons and with always expanded groups

                                0

                                This is a sample project for article Custom XtraNavBar view: XPExplorer view without expand/collapse buttons and with always expanded groups. It demonstrates how to implement a custom NavBar view, whose groups are always expanded and cannot be collapsed. For the sake of the example, we 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.

                                You must  log in  or  register  to leave comments
                                Select file
                                • CustomView.cs
                                • NavBar.cs
                                Select language
                                • C#
                                • VB.NET
                                Select version
                                • v2008 vol 2.2 - v2012 vol 2.8
                                using System;
                                using System.Drawing;
                                using DevExpress.Utils;
                                using DevExpress.Utils.Drawing;
                                using DevExpress.XtraNavBar;
                                using DevExpress.XtraNavBar.ViewInfo;
                                
                                namespace CustomView {
                                    public class NoExpandButtonViewNavBarViewInfo : XPExplorerBarNavBarViewInfo {
                                        public NoExpandButtonViewNavBarViewInfo(NavBarControl navBar) : base(navBar) {
                                        }
                                        // prevents expanding/collapsing of a group
                                        protected override void DoGroupClick(NavBarHitInfo hitInfo) { }
                                    }
                                
                                    public class NoExpandButtonViewNavBarGroupPainter : XPExplorerBarNavGroupPainter {
                                        public NoExpandButtonViewNavBarGroupPainter(NavBarControl navBar) : base(navBar) {}
                                        protected override ObjectPainter CreateOpenCloseButtonPainter() { 
                                            return new NoExpandButtonOpenCloseButtonObjectPainter(); 
                                        }
                                    }
                                
                                    // don't draw a button
                                    public class NoExpandButtonOpenCloseButtonObjectPainter : ExplorerBarOpenCloseButtonObjectPainter {
                                        protected override void DrawNormal(ObjectInfoArgs e, AppearanceObject appearance) {}
                                        protected override void DrawHot(ObjectInfoArgs e, AppearanceObject appearance) {}
                                        public override Rectangle GetObjectClientRectangle(ObjectInfoArgs e) {
                                            return Rectangle.Empty;
                                        }
                                    }
                                
                                    // register view
                                    public class NoExpandButtonViewInfoRegistrator : XPExplorerBarViewInfoRegistrator {
                                        internal const string CustomViewName = "NoExpandButtonView";
                                        public override string ViewName { get { return CustomViewName; } }
                                        public override BaseNavGroupPainter CreateGroupPainter(NavBarControl navBar) { 
                                            return new NoExpandButtonViewNavBarGroupPainter(navBar); 
                                        }
                                        public override NavBarViewInfo CreateViewInfo(NavBarControl navBar) { 
                                            return new NoExpandButtonViewNavBarViewInfo(navBar); 
                                        }
                                    }
                                }