Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Outlook加载项和禁用/隐藏自定义菜单项_C#_Outlook_Ribbon_Outlook Addin_Office Interop - Fatal编程技术网

C# Outlook加载项和禁用/隐藏自定义菜单项

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

我已经创建了一个Outlook加载项,并且正在使用XML功能区配置文件指定一个新选项卡和按钮。该按钮将加载到outlook中的新选项卡中。现在,有时,基于用户,我们希望能够隐藏或禁用这些按钮。通过Outlook Interop api禁用自定义选项卡上的菜单按钮的最简单方法是什么

我的第一个猜测是,在创建功能区后,我需要遍历一些命令栏集合,然后搜索菜单按钮,但我不确定这些集合在哪里

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();