How to access checkstage block in Office addin?

I have the boolean property Settings.Default.MarkAsRead in the Setting.settings file, which can be accessed in my Ribbon class. What I would like to do is set the checkbox value in my backstage section depending on the value of this property. Also, if the user modifies it, I will need to save the new value.

Anyway, can I do this?

This is my (simplified) 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> 
+2
source share
1 answer

I did not find a way to access the xml elements from the Ribbon_Load method, so I created a Boolean property in the ribbon class that I update with the GetPressed and OnAction :

XML:

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

WITH#:

  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; } 
+2
source

Source: https://habr.com/ru/post/1269483/


All Articles