I used a ribbon XML file to create a custom tab which contains a togglebutton. The button is meant to toggle the visibility of a custom task pane and works 开发者_运维知识库great. The problem is that when the user close the custom task pane, the toggle button is now out of sync. How do I programmaticly access the togglebutton so I can change its IsChecked value?
You need to handle the VisibleChanged event. Add the following method to your ThisAddIn class - when the user closes the task pane 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;
}
(see more info on this in Walkthrough: Synchronizing a Custom Task Pane with a Ribbon Button)
精彩评论