【问题标题】:Add ribbon (tab) to contact form outlook addin将功能区(选项卡)添加到联系表单 Outlook 插件
【发布时间】:2013-01-18 23:02:21
【问题描述】:

我正在尝试在 C# 中的 Outlook 联系人中添加功能区/选项卡。我添加了一个功能区,并在其 xml 中编写了以下代码。

<tab idMso="TabAddIns" label="mySoftwareTab">
    <group id="ContentGroup" label="Appointments">
      <button id="GetAppointment" label="Get Appointments" screentip="Appointment" imageMso="ViewAppointmentInCalendar" onAction="GetAppointmentPressed" size="large"
              supertip="Get all appointments."/>
    </group>
  </tab>

这会在包括主区域在内的每个屏幕中创建选项卡(如图所示,mySoftwareTab 位于位置 A 和 B)

但是,如果我将 idMso 更改为 TabContact,它只会在联系人上创建一个按钮(图像中的 C 位置)。

我希望仅在 Outlook 联系页面上创建选项卡(在图像中的位置 B)。 我该怎么做?

【问题讨论】:

    标签: c# .net vsto outlook-addin


    【解决方案1】:

    添加一个 getVisible 回调方法,并根据您希望它出现的检查器窗口对该方法进行门控。

    <tab idMso="TabAddIns" label="mySoftwareTab"
         getVisible="myTab_GetVisible">
    

    然后,创建名为 mySoftwareTab_GetVisible 的回调委托方法

    更新由原始海报 (Kash) 提供的最终解决方案,因此归功于他。 ...重新发布给其他查看问题和答案的人。

        public bool myTab_GetVisible(Office.IRibbonControl control) 
        { 
            if (control.Context is Outlook.Inspector) 
            { 
                Outlook.Inspector oInsp = control.Context as Outlook.Inspector; 
                if (oInsp.CurrentItem is Outlook.ContactItem) 
                { 
                    return true; 
                } 
                else 
                { 
                    return false; 
                } 
            } 
            else 
            { 
                return false; 
            } 
        }
    

    【讨论】:

    • if (control.Context is Outlook.ContactItem) 这个条件永远不会成立。
    • 位更改后,以下是工作代码。 public bool myTab_GetVisible(Office.IRibbonControl control) { if (control.Context is Outlook.Inspector) { Outlook.Inspector oInsp = control.Context as Outlook.Inspector; if (oInsp.CurrentItem is Outlook.ContactItem) { return true; } else { return false; } } else { return false; } }
    猜你喜欢
    • 2010-12-24
    • 2014-07-10
    • 2013-05-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多