How to access backstage checkbox value in an Office addin?

后端 未结 1 576
终归单人心
终归单人心 2021-01-06 15:46

I have a boolean property Settings.Default.MarkAsRead in the Setting.settings file, which I can access in my Ribbon class. What I\'d like to do is set the value

相关标签:
1条回答
  • 2021-01-06 16:32

    I didn't find a way to access the xml elements from the Ribbon_Load method, so I've created a boolean property in the ribbon class that I update using the GetPressed and OnAction callbacks:

    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;
        }
    
    0 讨论(0)
提交回复
热议问题