How to extend the context menu inside the rehosted workflow designer? -
we using rehosted designer (currently wf 4.0) lot of custom activities, of them have custom designers. bunch of them, add entries context menu of designer when in design mode. i'm talking menu:
e.g. xaml coded activity have "open source..." entry load xaml source of specific activity new designer. must add entry menu, , when clicked figure out on activity clicked. both parts unclear me. how can achieve that?
in wf 3 there activitydesignerverb class that. in wf 4 there seems workflowdesigner.context.services.publish<icommandservice>(...), can't figure out how use add custom action context menu. how can that?
this entry shows internal debugger commands, want add new command.
solving in host
if want solve on workflow designer host, , not in individual activities, it's quite simple , straightforward this.
when host workflow designer , create workflow designer, can access contextmenu
property , modify items
collection.
var wfd = new workflowdesigner(); wfd.contextmenu.items.add(new menuitem() { header = "hello", command = yourcommand, });
if want different menu items each activity, can subscribe selectionchanged
event:
wfd.context.items.subscribe<selection>(selectionchanged);
and implement own logic:
private void selectionchanged(selection selection) { // remove old menu item if (oldmenuitem != null) { wfd.contextmenu.items.remove(oldmenuitem); oldmenuitem = null; } var modelitem = selection.primaryselection; if (selection.selectioncount == 1 && modelitem != null) { // activity type var activitytype = modelitem.itemtype; var menuitem = new menuitem() { /* ... */ }; wfd.contextmenu.items.add(menuitem); oldmenuitem = menuitem; } }
solving in activity designer
if want show specific context menu item regardless of workflow designer ui hosted, can create custom item in activity designer xaml:
<sap:activitydesigner.contextmenu> <contextmenu> <menuitem header="show" command="{binding yourcommand}"/> </contextmenu> </sap:activitydesigner.contextmenu>
Comments
Post a Comment