Office Ribbon: How to Access a Control When a Ribbon Was Created Using XML

I used a ribbon XML file to create a custom tab containing a togglebutton switch. The button is designed to switch the visibility of a custom taskbar and works great. The problem is that when the user closes the user taskbar, the toggle button is now out of sync. How to programmatically access a switch so that I can change its IsChecked value?

+1
source share
1 answer

You need to handle the VisibleChanged event . Add the following method to your ThisAddIn class: when the user closes the taskbar by clicking the Close button (X), this method updates the state of the toggle button on the ribbon.

private void taskPaneValue_VisibleChanged(object sender, System.EventArgs e)
{
    Globals.Ribbons.ManageTaskPaneRibbon.toggleButton1.Checked = 
        taskPaneValue.Visible;
}

(For more on this, see the Walkthrough: Synchronizing a Custom Task Pane Using the Ribbon Button )

-1
source

All Articles