outlook - 如何访问 Office 插件中的后台复选框值?

标签 outlook outlook-addin

我在Setting.settings 文件中有一个 bool 属性Settings.Default.MarkAsRead,我可以在我的Ribbon 类中访问该属性。我想要做的是根据此属性的值设置后台部分中复选框的值。另外,如果用户修改它,我需要保存新值。

有什么办法可以做到这一点吗?

这是我的(简化的)xml:

<?xml version="1.0" encoding="UTF-8"?>
<customUI onLoad="Ribbon_Load" 
         xmlns="http://schemas.microsoft.com/office/2009/07/customui"> 
  <backstage>
    <tab id="MyBackstageSection" label="MyBackstageSection"
                columnWidthPercent="30" insertAfterMso="TabInfo" visible="true" >
      <firstColumn>
        <group id="grpOne" label="Configuration">
          <bottomItems>

              <checkBox id="markAsRead" label="Mark as read"
                                 getPressed="markAsRead_GetPressed" />

              <button id="save" label="Save Preferences" onAction="save_Click"/>

          </bottomItems>         
        </group>
      </firstColumn>
    </tab>
  </backstage>
</customUI>

最佳答案

我没有找到从 Ribbon_Load 方法访问 xml 元素的方法,因此我在功能区类中创建了一个 bool 属性,并使用 GetPressed 更新该属性code> 和 OnAction 回调:

xml:

<checkBox id="markAsRead" label="Mark as read" 
            onAction="markAsRead_OnAction" getPressed="markAsRead_GetPressed"/>

c#:

    private bool MarkAsRead { get; set; }

    public bool markAsRead_GetPressed(Office.IRibbonControl control)
    {
        this.MarkAsRead = Settings.Default.MarkAsRead;
        return this.MarkAsRead;
    }

    public void markAsRead_OnAction(Office.IRibbonControl control, bool isPressed)
    {
        this.MarkAsRead = isPressed;
    }

关于outlook - 如何访问 Office 插件中的后台复选框值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8039187/

相关文章:

macos - 在 Mac 上输入 Outlook 2011 时如何禁用自动大写?

html - Microsoft Outlook 打破了我的 table

outlook - 我可以在 Outlook 中添加自定义/电子邮件域列吗?

vb.net - VSTO 在 Outlook 中创建类似 "notification bar"的消息

python win32com outlook 2013 SendUsingAccount返回异常

excel - 如何在 Outlook 中获取任务的完成时间

c# - 更改在 outlook html 电子邮件中呈现的电子邮件地址超链接的颜色

c# VSTO Outlook 链接图像没有被嵌入

c# - Outlook.MailItem.Sender 为空-从电子邮件地址获取

c# - 获取 Outlook 2010 规则说明