Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
4165
How to set Toolbar Width
posted

Hello.

How can I control the width of the rows in the toolbar manager or the width of the toolbars themselves?

Thanks.

  • 20872
    Suggested Answer
    Offline posted

    Hello,

    It is not recommended to change the size of the Toolbar elements, but it is possible with a CreationFilter. I have created a small sample and if you use the following CreationFilter you will be able to manipulate the width :

      class CreationFilterToolbarWidth : IUIElementCreationFilter
        {
            #region IUIElementCreationFilter Members

            public void AfterCreateChildElements(UIElement parent)
            {
                 UltraToolbarsDockAreaUIElement toolbarParent = parent as UltraToolbarsDockAreaUIElement;
                 if (toolbarParent != null)
                 {

                    //looping through the Toolbars to make them with Equal width 
                    foreach(ToolbarUIElement uiEL in toolbarParent.ChildElements)  

                     {       

                     //Setting the desired width to each of the Toolbars
                     uiEl.Rect = new Rectangle(uiEl.Rect.X, uiEl.Rect.Y, 500, uiEl.Rect.Height);

                    }
                 }
            }

            public bool BeforeCreateChildElements(UIElement parent)
            {
                return false;
            }

            #endregion
        }

     And after that you just need to assing an instance of this class to your UltraToolbarsManager component like :

     ultraToolbarsManager1.CreationFilter = new CreationFilterToolbarWidth();

    Please let me know if you have any other questions.