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

时间:2011-11-07 16:12:04

标签: outlook outlook-addin

我在Setting.settings文件中有一个布尔属性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>

1 个答案:

答案 0 :(得分:2)

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

的xml:

OnAction

C#:

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