c# - Avalondock MVVM Layout -
so question has been asked before but not answered or not answered way like
i know how create layout want achive, using layoutanchorablepanegroup
, layoutanchorablepane
, layoutdocument
in xaml, wanted use avalondock in mvvm way, reducing xaml to:
<avalondock:dockingmanager x:name="dockingmanager" datacontext="{binding dockmanagerviewmodel}" documentssource="{binding documents}" anchorablessource="{binding anchorables}" loaded="dockingmanager_loaded" unloaded="dockingmanager_unloaded">
filling documents
, anchorables
makes desired windows appear in dockingmanager, don't see how can secify location in appear.
how can specify rules ( prefferably in xaml ), build specific layout, without loosing mvvm separation?
e.g.: objects of type should go togehter in layoutanchorablepane
on right, objects of type b go in layoutanchorablepane
on left etc..
thanks in advance.
i went same situation. , found solution tricky works me.
followed solution on code project , implimented save , load layout.
note first time when application starts not have layout need create xml desired layout , later on can load saved layout. hope helps.
example docking manager :
<xcad:dockingmanager x:name="dockingmanagerdockview" anchorablessource="{binding anchorablesource}" documentssource="{binding documentsource}" utility:avalondocklayoutserializer.savelayoutcommand="{binding savelayoutcommandonexit}" utility:avalondocklayoutserializer.loadlayoutcommand="{binding loadlayoutcommand}"> <xcad:dockingmanager.theme> <xcad:metrotheme /> </xcad:dockingmanager.theme> <xcad:dockingmanager.layoutupdatestrategy> <pane:layoutinitializer/> </xcad:dockingmanager.layoutupdatestrategy> <xcad:dockingmanager.resources> <datatemplate datatype="{x:type viewmodels:explorerviewmodel}"> <views:explorerview /> </datatemplate> <datatemplate datatype="{x:type viewmodels:tableofcontentviewmodel}"> <views:tableofcontentview x:name="tocview" focusable="true"> <views:tableofcontentview.inputbindings> <keybinding key="f5" command="{binding gridf5command}"/> </views:tableofcontentview.inputbindings> </views:tableofcontentview> </datatemplate> <datatemplate datatype="{x:type viewmodels:propertyviewmodel}"> <views:propertyview /> </datatemplate> <datatemplate datatype="{x:type viewmodels:searchviewmodel}"> <views:searchpanel /> </datatemplate> <datatemplate datatype="{x:type viewmodels:documentviewmodel}"> <views:documentview /> </datatemplate> <datatemplate datatype="{x:type viewmodels:reindexpanelviewmodel}"> <views:reindexpanel /> </datatemplate> </xcad:dockingmanager.resources> <xcad:dockingmanager.layoutitemcontainerstyleselector> <pane:panesstyleselector> <pane:panesstyleselector.toolstyle> <style targettype="{x:type xcad:layoutanchorableitem}"> <setter property="title" value="{binding model.title}"/> <setter property="visibility" value="{binding model.isvisible, mode=twoway, converter={staticresource booltovisibilityconverter}, converterparameter={x:static visibility.hidden}}"/> <setter property="contentid" value="{binding model.contentid}"/> <setter property="flowdirection" value="lefttoright"/> <setter property="uselayoutrounding" value="false"/> <setter property="iconsource" value="{binding model.iconsource}"/> </style> </pane:panesstyleselector.toolstyle> <pane:panesstyleselector.filestyle> <style targettype="{x:type xcad:layoutitem}"> <setter property="title" value="{binding model.title}"/> <setter property="tooltip" value="{binding model.filepath}"/> <setter property="contentid" value="{binding model.contentid}"/> <setter property="canclose" value="false"/> </style> </pane:panesstyleselector.filestyle> </pane:panesstyleselector> </xcad:dockingmanager.layoutitemcontainerstyleselector> <xcad:layoutroot> <xcad:layoutpanel orientation="horizontal"> <xcad:layoutanchorablepanegroup> <xcad:layoutanchorablepane name="explorer" dockminwidth="250"/> <xcad:layoutanchorablepane name="toc" dockminwidth="500"/> <xcad:layoutanchorablepane name="property" dockminwidth="300" /> <xcad:layoutanchorablepane name="search" dockminwidth="300" /> <xcad:layoutanchorablepane name="reindex" dockminheight="300" /> </xcad:layoutanchorablepanegroup> <xcad:layoutdocumentpanegroup > <xcad:layoutdocumentpane/> </xcad:layoutdocumentpanegroup> </xcad:layoutpanel> </xcad:layoutroot> </xcad:dockingmanager>
Comments
Post a Comment