Ribbon controls are updated with each other in the Custom XML functional area of vsto.

Source: Internet
Author: User

Generally, in vsto, you can use a visual editor to develop the ribbon functional area. The reference and modification property values between controls are no different from winform development, which is very convenient, however, to implement more complex functions, you have to go to the development in the XML editor, but it seems that mutual access between controls is not so direct, because the XML designer uses a large number of callback mechanisms in the fluent UI, that is to say, the attribute modification of each control must pass the callback method. On the other hand, because of the caching mechanism, ui updates must also be triggered by invalidatecontrol.

The following example shows how to modify the value of the label control by clicking the button.

<?xml version="1.0" encoding="UTF-8"?><customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">  <ribbon>    <tabs>      <tab idMso="TabAddIns">        <group id="MyGroup" label="My Group">          <labelControl id="mylabel" getLabel="GetLabel"/>          <button id="mybutton" label="Click Me" onAction="Click"/>        </group>      </tab>    </tabs>  </ribbon></customUI>

Add code:

 private string _label = "Label";

public string GetLabel(Office.IRibbonControl control)
{
return _label;
}

public void Click(Office.IRibbonControl control)
{
_label = "Changed By Button";
ribbon.InvalidateControl("mylabel");
}

Note the following:

1. The label and getlabel of labelcontrol cannot appear at the same time in XML; otherwise, the label control cannot be seen at vsto startup.

2. All controls have at least one ID attribute. Otherwise, the control cannot be seen during vsto startup.

3. The callback function must be defined according to the proxy prototype.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.