How to create a dynamic submenu in contextmenu for outlook (VSTO)

十年热恋 提交于 2019-12-06 15:01:50

问题


I have a ribbon xml where I want to add something similar as in the picture. I tried create a button and connect the menu to the button but I never got the arrow indication there is a underlying menu. I have no faith at all in that button is the correct element to use. Been googling for hours now and would be happy if anyone can send me in some kind of direction. There is no problem for me to add the element in the context menu, the problem is the dynamic menu linked to the first element.


回答1:


The control type you're looking for is dynamicMenu

Here is the ribbon XML:

<dynamicMenu id="mycustomid" label="My custom label" getContent="GetMyCustomContent" />

And the code:

public string GetMyCustomContent(IRibbonControl control)
{
    return "<menu xmlns=\"http://schemas.microsoft.com/office/2009/07/customui\">"
        + "<button id=\"anotherid\" label=\"another label\" onAction=\"DoWhatever\"/>"
        + "</menu>";
}

public string DoWhatever(IRibbonControl control)
{
}


来源:https://stackoverflow.com/questions/51380155/how-to-create-a-dynamic-submenu-in-contextmenu-for-outlook-vsto

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