C# Outlook加载项和禁用/隐藏自定义菜单项
我已经创建了一个Outlook加载项,并且正在使用XML功能区配置文件指定一个新选项卡和按钮。该按钮将加载到outlook中的新选项卡中。现在,有时,基于用户,我们希望能够隐藏或禁用这些按钮。通过Outlook Interop api禁用自定义选项卡上的菜单按钮的最简单方法是什么 我的第一个猜测是,在创建功能区后,我需要遍历一些命令栏集合,然后搜索菜单按钮,但我不确定这些集合在哪里C# Outlook加载项和禁用/隐藏自定义菜单项,c#,outlook,ribbon,outlook-addin,office-interop,C#,Outlook,Ribbon,Outlook Addin,Office Interop,我已经创建了一个Outlook加载项,并且正在使用XML功能区配置文件指定一个新选项卡和按钮。该按钮将加载到outlook中的新选项卡中。现在,有时,基于用户,我们希望能够隐藏或禁用这些按钮。通过Outlook Interop api禁用自定义选项卡上的菜单按钮的最简单方法是什么 我的第一个猜测是,在创建功能区后,我需要遍历一些命令栏集合,然后搜索菜单按钮,但我不确定这些集合在哪里 protected override Microsoft.Office.Core.IRibbonExtensibi
protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
{
this.ribbon = new MyRibbon();
// loop through tabs and ribbon items, look for my custom control, and enabled/disable specific buttons.
return this.ribbon;
}
很抱歉回答我自己的问题。我终于明白了。在xml配置中,有一个用于按钮/组/选项卡的getVisible回调 因此,您只需在xml中添加回调,在我的例子中,我是为一个组添加回调的:
<ribbon>
<tabs>
<tab idQ="myNs:myTab" label="My Label" >
<group id="settingsGroup" label="Settings" getVisible="Control_Visible" >
<button id="preferences" label="Preferences" image="configuration.png"
screentip="Preferences" size="large" onAction="Settings_Click" supertip="Preferences" />
</group>
</tab>
</tabs>
</ribbon>
public bool Control_Visible(Office.IRibbonControl control)
{
// In order to maintain a reference to the groups, I store the controls into a List<Office.IRibbonControl>.
if(!this.groupControls.Contains(control))
{
this.groupControls.Add(control);
}
// logic here to determine if it should return true or false to be visible...
return true;
}
this.ribbon.Invalidate();