VSTO Outlook 插件功能区组未显示在功能区上
VSTO Outlook Addin Ribbon Group Not Showing on Ribbon
我有一个 Outlook 插件,它使用两个按钮将组添加到功能区。在我添加第二个按钮之前它工作得很好,但它们具有相同的属性,只是点击处理程序不同。它显示在自定义功能区菜单中的正确位置,但显示为灰色。当它显示为灰色时,这意味着什么?可能是什么原因导致的?加载项仍处于加载状态,并且由于任何原因未被停用,这在为什么加载项将被停用的原因列表中。
通过关注这个问题的答案:Outlook addin Home tab with custom button
我能够让按钮显示在主选项卡上的已读邮件 window 中。与该答案的唯一区别是我使用了 TabReadMessage 而不是 TabMail(根据文档)。在添加第二个按钮之前,这非常有效。您可以在屏幕截图中看到两个按钮,Archive Message 和 Archive Message As。
见图:
任何人都知道为什么会发生这种情况。为什么添加第二个按钮会使它停止显示?
有没有办法调试它并查看发生了什么?
任何帮助将不胜感激,因为我一直在寻找答案。
谢谢
编辑:
为我的功能区元素的属性生成的代码。
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OutlookRibbon));
this.tab1 = this.Factory.CreateRibbonTab();
this.group1 = this.Factory.CreateRibbonGroup();
this.button1 = this.Factory.CreateRibbonButton();
this.button2 = this.Factory.CreateRibbonButton();
this.tab1.SuspendLayout();
this.group1.SuspendLayout();
//
// tab1
//
this.tab1.ControlId.ControlIdType = Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Office;
this.tab1.ControlId.OfficeId = "TabReadMessage";
this.tab1.Groups.Add(this.group1);
this.tab1.Label = "TabReadMessage";
this.tab1.Name = "tab1";
//
// group1
//
this.group1.Items.Add(this.button1);
this.group1.Items.Add(this.button2);
this.group1.Label = "Archive";
this.group1.Name = "group1";
this.group1.Position = this.Factory.RibbonPosition.BeforeOfficeId("GroupRespond");
//
// button1
//
this.button1.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.button1.Description = "Archive Message";
this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
this.button1.Label = "Archive Message";
this.button1.Name = "button1";
this.button1.ScreenTip = "Archives Message";
this.button1.ShowImage = true;
this.button1.SuperTip = "Archives Message";
this.button1.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button1_Click);
//
// button2
//
this.button2.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.button2.Description = "Archive Message As";
this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image")));
this.button2.Label = "Archive Message As";
this.button2.Name = "button2";
this.button2.ScreenTip = "Archive message in designated place";
this.button2.ShowImage = true;
this.button2.SuperTip = "Archives message in designated place";
this.button2.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button2_Click);
//
// OutlookRibbon
//
this.Name = "OutlookRibbon";
this.RibbonType = resources.GetString("$this.RibbonType");
this.Tabs.Add(this.tab1);
this.Load += new Microsoft.Office.Tools.Ribbon.RibbonUIEventHandler(this.OutlookRibbon_Load);
this.tab1.ResumeLayout(false);
this.tab1.PerformLayout();
this.group1.ResumeLayout(false);
this.group1.PerformLayout();
}
编辑 2:
突然间,VS 中的每一个插件都会导致错误
Ribbon_GetDCVisible 说调用函数 GetVisisble 时发生异常。不知道为什么,但我打开了 show UI errors 所以也许这让它们变灰了?虽然不确定,因为每个插件都会发生这种情况。即使是全新的空白。
灰色按钮表示您的自定义 UI 已禁用。很可能您在标记中遇到了错误,或者您的代码触发了异常。 Office 应用程序禁用行为异常的加载项。
我对初始 post 有一堆问题,所以决定将它们也作为答案发布。很难将它们全部识别为评论。其中任何一个都可以解决问题。
到目前为止,您有哪些 XML 标记?您是否尝试从功能区设计器中提取它?
添加其他按钮后,Outlook 中是否出现 UI 错误?有关详细信息,请参阅 How to: Show Add-in User Interface Errors。
getVisible回调有什么异常?您是否尝试调试代码?
我有一个 Outlook 插件,它使用两个按钮将组添加到功能区。在我添加第二个按钮之前它工作得很好,但它们具有相同的属性,只是点击处理程序不同。它显示在自定义功能区菜单中的正确位置,但显示为灰色。当它显示为灰色时,这意味着什么?可能是什么原因导致的?加载项仍处于加载状态,并且由于任何原因未被停用,这在为什么加载项将被停用的原因列表中。
通过关注这个问题的答案:Outlook addin Home tab with custom button
我能够让按钮显示在主选项卡上的已读邮件 window 中。与该答案的唯一区别是我使用了 TabReadMessage 而不是 TabMail(根据文档)。在添加第二个按钮之前,这非常有效。您可以在屏幕截图中看到两个按钮,Archive Message 和 Archive Message As。
见图:
任何人都知道为什么会发生这种情况。为什么添加第二个按钮会使它停止显示?
有没有办法调试它并查看发生了什么?
任何帮助将不胜感激,因为我一直在寻找答案。
谢谢
编辑:
为我的功能区元素的属性生成的代码。
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OutlookRibbon));
this.tab1 = this.Factory.CreateRibbonTab();
this.group1 = this.Factory.CreateRibbonGroup();
this.button1 = this.Factory.CreateRibbonButton();
this.button2 = this.Factory.CreateRibbonButton();
this.tab1.SuspendLayout();
this.group1.SuspendLayout();
//
// tab1
//
this.tab1.ControlId.ControlIdType = Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Office;
this.tab1.ControlId.OfficeId = "TabReadMessage";
this.tab1.Groups.Add(this.group1);
this.tab1.Label = "TabReadMessage";
this.tab1.Name = "tab1";
//
// group1
//
this.group1.Items.Add(this.button1);
this.group1.Items.Add(this.button2);
this.group1.Label = "Archive";
this.group1.Name = "group1";
this.group1.Position = this.Factory.RibbonPosition.BeforeOfficeId("GroupRespond");
//
// button1
//
this.button1.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.button1.Description = "Archive Message";
this.button1.Image = ((System.Drawing.Image)(resources.GetObject("button1.Image")));
this.button1.Label = "Archive Message";
this.button1.Name = "button1";
this.button1.ScreenTip = "Archives Message";
this.button1.ShowImage = true;
this.button1.SuperTip = "Archives Message";
this.button1.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button1_Click);
//
// button2
//
this.button2.ControlSize = Microsoft.Office.Core.RibbonControlSize.RibbonControlSizeLarge;
this.button2.Description = "Archive Message As";
this.button2.Image = ((System.Drawing.Image)(resources.GetObject("button2.Image")));
this.button2.Label = "Archive Message As";
this.button2.Name = "button2";
this.button2.ScreenTip = "Archive message in designated place";
this.button2.ShowImage = true;
this.button2.SuperTip = "Archives message in designated place";
this.button2.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(this.button2_Click);
//
// OutlookRibbon
//
this.Name = "OutlookRibbon";
this.RibbonType = resources.GetString("$this.RibbonType");
this.Tabs.Add(this.tab1);
this.Load += new Microsoft.Office.Tools.Ribbon.RibbonUIEventHandler(this.OutlookRibbon_Load);
this.tab1.ResumeLayout(false);
this.tab1.PerformLayout();
this.group1.ResumeLayout(false);
this.group1.PerformLayout();
}
编辑 2:
突然间,VS 中的每一个插件都会导致错误 Ribbon_GetDCVisible 说调用函数 GetVisisble 时发生异常。不知道为什么,但我打开了 show UI errors 所以也许这让它们变灰了?虽然不确定,因为每个插件都会发生这种情况。即使是全新的空白。
灰色按钮表示您的自定义 UI 已禁用。很可能您在标记中遇到了错误,或者您的代码触发了异常。 Office 应用程序禁用行为异常的加载项。
我对初始 post 有一堆问题,所以决定将它们也作为答案发布。很难将它们全部识别为评论。其中任何一个都可以解决问题。
到目前为止,您有哪些 XML 标记?您是否尝试从功能区设计器中提取它?
添加其他按钮后,Outlook 中是否出现 UI 错误?有关详细信息,请参阅 How to: Show Add-in User Interface Errors。
getVisible回调有什么异常?您是否尝试调试代码?