Access Ribbon Elements Programmatically in XML Ribbon

后端 未结 1 913
日久生厌
日久生厌 2020-12-20 16:13

This seems to have been asked several times on here with no real answer:

Accessing Ribbon Controls Programatically in an XML Ribbon

Office Ribbon: How to acc

相关标签:
1条回答
  • 2020-12-20 16:42

    There is no way to programmatically access Ribbon elements when using Ribbon XML. If you want to change the state of the Ribbon controls - you need to use IRibbonUI.Invalidate() to force a new rendering of the layout (potentially using properties that trigger different behaviors at rendering time via callbacks). This can be a good thing as you have more control over when drawing occurs if you are changing multiple items' state.

    See related SO post on updating Ribbon UI control state.

    If you want programmatic access to Ribbon elements, you should use the Ribbon Designer. However, as stated on MSDN, the designer doesn't support all customizations. Some speculate that the designer just wraps the Ribbon XML up for you under the hood.

    You just have to learn the callback mechanism utilized by the Ribbon XML - there is no control tree for you to gain access to.

    0 讨论(0)
提交回复
热议问题