【发布时间】:2015-07-28 16:48:28
【问题描述】:
我有一个使用两个按钮将组添加到功能区的 Outlook 插件。在我添加第二个按钮之前它运行良好,但它们具有相同的属性,只是不同的点击处理程序。它显示在自定义功能区菜单中的正确位置,但显示为灰色。当它变灰时是什么意思,什么可能导致它?插件仍处于加载状态,并且未因插件被停用的原因列表中的任何原因而被停用。
按照这个问题的答案:Outlook addin Home tab with custom button
我能够让按钮显示在主选项卡上的阅读邮件窗口中。与该答案的唯一区别是我使用了 TabReadMessage 而不是 TabMail (根据文档)。在添加第二个按钮之前,这非常有效。您可以在屏幕截图中看到这两个按钮,存档消息和存档消息。
看图:
任何人都知道为什么会发生这种情况。为什么添加第二个按钮会使其停止显示?
有没有办法调试它并查看发生了什么?
任何帮助将不胜感激,因为我一直在寻找答案。
谢谢
编辑:
为我的功能区元素的属性生成的代码。
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 时发生异常。不知道为什么,但我打开了显示 UI 错误,所以也许这会使它们变灰?不过不确定,因为每个插件都会发生这种情况。甚至是全新的空白。
【问题讨论】:
-
你能给我们看看代码吗?
-
这是一段很好的代码。不确定要准确显示哪些部分。应该在启动时运行的代码的唯一部分是正常的 VSTO 插件代码和一些被添加到 dict 的东西。我想我可以发布功能区元素的属性。
-
看起来不错,奇怪的是它对一个按钮的工作方式,但添加第二个按钮是隐藏的。我有几个建议。 a) 打开日志记录,我的第 7 点 here 和 b) 尝试将按钮放在不同的选项卡上,看看是否可以缩小问题域的范围,尝试在
.group1.Items.Add(this.button1);之前指定按钮名称,尝试制作带有 XML 的按钮,或者看看你是否可以这样做:stackoverflow.com/questions/17216199/… -
会试一试并报告,谢谢。添加第二个按钮会产生这种影响是很奇怪的,我添加的唯一其他东西是 2 个表单,但它们非常基本并且在启动时不会被调用,所以它应该无关紧要
-
至于你在那个答案中的第 7 点,我只是设置了那些环境变量? VSTO 日志警报出现在哪里?
标签: c# outlook vsto outlook-addin