0
我已将自定义切换按钮添加到Outlook 2013中的新电子邮件功能区。当按钮打开时,它会将用户属性添加到邮件消息中。功能区切换按钮getPressed()在预期时不会被调用
public void OnLockButton(Office.IRibbonControl control, bool pressed)
{
Outlook.MailItem mi = Globals.ThisAddIn.Application.ActiveInspector().CurrentItem as Outlook.MailItem;
var userProp = mi.UserProperties.Add("MyIsLocked", Outlook.OlUserPropertyType.olYesNo, false);
userProp.Value = pressed;
// Make sure we update the ribbon
ribbon.Invalidate();
}
按钮的“切换”状态正在与检查用户属性的状态getPressed()回调更新:
public bool GetLockButtonPressed(Office.IRibbonControl control)
{
Outlook.MailItem mailItem = Globals.ThisAddIn.Application.ActiveInspector().CurrentItem as Outlook.MailItem;
var userProp = mailItem.UserProperties.Find("NMIsLocked");
bool isLocked = (userProp != null && userProp.Value);
return isLocked;
}
这是所有工作得很好。
问题发生时:
- 打开一封新邮件
- 接通切换按钮
- 丢弃邮件
- 打开一封新邮件
在这一点切换按钮看起来像是在新邮件消息上打开,即使用户属性没有设置在该消息上即
在调试器中,我可以看到getPressed()没有被新的消息调用,所以我认为功能区按钮的状态与上次绘制时相同。
我有过的一些想法包括当邮件信息打开(或关闭?)时,强制功能区无效或者是否有其他方法我错过了?
我正在寻找与Outlook中的“高优先级”切换按钮类似的功能。
这http://social.msdn.microsoft.com/Forums/vstudio/en-US/ae3049ce-4c16-4d24-9183-961fc6be5944/vsto-c-outlook-addin-default-toggle-button -state?forum = vsto应该会有帮助。回答的人已经写了一本书! http://www.slovaktech.com/Books.htm – 2014-09-19 15:59:35