我在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/