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
485
Enabling / Diabling tools
posted

Hi,

we're creating tools for our ribbon dynamically using spring (www.springframework.net). The tools get registered on the toolbar manager right at creation and are added to groups by its keys.

Layout (image, size, caption, etc.) of the tools is provided while construction using decorators which implement functionality to set appropriate appearance properties, e.g. something like this

        /// <summary>
        /// Decorates a tool
        /// </summary>
        /// <param name="tool">tool to decorate</param>
        public void Decorate(ITool tool)
        {
            ((ToolBase)tool).SharedProps.Caption = this.caption;
        }

Some of the tools are disabled upon creation using this technique:

        /// <summary>
        /// Decorates a tool
        /// </summary>
        /// <param name="tool">tool to decorate</param>
        public void Decorate(ITool tool)
        {
            ((ToolBase) tool).SharedProps.Enabled = this.enabled;
        }

Fine. This works as expected. Now, sometime the we decide to activate the tools again at runtime, e.g. if in a list a item was selected. In our situation this means, that we activate all tools on a RibbonTab. We inherited from the RibbonTab and call the following function:

        private void OnEnabledChanged(bool newValue)
        {
            this.enabled = newValue;
            foreach (RibbonGroup  group in base.Groups)
            {
                foreach (var tool in group.Tools)
                {
                    tool.SharedProps.Enabled = this.enabled;
                }
            }
        }

This activates all tools as expected. But, the first time I now click on a PopupControlContainerTool the tool gets deactivated and can not be accessed anymore until I again activate it (e.g. by selecting another item from the list as mentioned above).

 

Regards,

Michael

Parents Reply Children
No Data