Office功能区:如何使用XML创建功能区时访问控件 [英] Office Ribbon: How to access a control when the ribbon was created using XML

查看:142
本文介绍了Office功能区:如何使用XML创建功能区时访问控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用功能区XML文件创建了一个自定义标签,其中包含一个切换按钮.该按钮用于切换自定义任务窗格的可见性,并且效果很好.问题在于,当用户关闭自定义任务窗格时,切换按钮现在不同步.如何以编程方式访问切换按钮,以便更改其IsChecked值?

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;
}

(请参阅演练:同步具有功能区按钮的自定义任务窗格)

这篇关于Office功能区:如何使用XML创建功能区时访问控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆