tabcontrol - Any example of changing menus and supporting closing for an 'AllActive' tabbed application? -


i'm cm newbie , trying head around cm. building application each tab allows user different functionality accessing server active work in tabs (if active) running async each other shell "conductor.collection.allactive" hope correct choice. looking suggestions or sample in 2 areas -

  1. i have main shell own application menu , tab control, , change application menuitems depending on tab selected , have menuitem clicks routed respective vm tab.

  2. since tabs potentially doing active work simultaneously, hoping example of how vm on each tab can participate in helping decide (via dialogs user) if application can closed if close menuitem or application x icon clicked. or if close should cancelled per user response (e.g. 'no' since there unsaved files).

any examples , suggestions appreciated.

i created sample of possible way this. using sharedviewmodel contains collection of menuitems. sharedviewmodel injected shellviewmodel , each tabviewmodel. menu control binds collection of menuitems.

when tab's onactivate fires menu items can updated tabviewmodel.

<hierarchicaldatatemplate datatype="{x:type viewmodels:menuitemviewmodel}"                                   itemssource="{binding path=menuitems}">             <contentcontrol cal:view.model="{binding}" />         </hierarchicaldatatemplate>    <menu ismainmenu="true"               itemssource="{binding sharedviewmodel.menuitems}" /> 

sharedviewmodel:

 public class sharedviewmodel : propertychangedbase     {         private list<menuitemviewmodel> _menuitems;          public list<menuitemviewmodel> menuitems         {             { return _menuitems; }             set             {                 _menuitems = value;                 notifyofpropertychange(() => menuitems);             }         }     } 

example of tabviewmodel updating menu:

 protected override void onactivate()         {             base.onactivate();              sharedviewmodel.menuitems = new list<menuitemviewmodel>                                             {                                                 new menuitemviewmodel                                                     {                                                         header = "mainmenuitem1",                                                         menuitems =                                                             new list<menuitemviewmodel>                                                                 {                                                                     new menuitemviewmodel {header = "submenuitem1"},                                                                     new menuitemviewmodel {header = "submenuitem2"},                                                                 }                                                     },                                                     new menuitemviewmodel                                                     {                                                         header = "mainmenuitem2",                                                         menuitems =                                                             new list<menuitemviewmodel>                                                                 {                                                                     new menuitemviewmodel {header = "submenuitem1"},                                                                     new menuitemviewmodel {header = "submenuitem2"},                                                                 }                                                     }                                             };         } 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -