How to access backstage checkbox value in an Office addin?

北战南征 提交于 2019-12-01 00:44:56

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;
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!