开发者

Office Ribbon: How to access a control when the ribbon was created using XML

开发者 https://www.devze.com 2023-03-27 23:53 出处:网络
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 wh

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)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号