wpf - Right way to put few UserControl Components on a Window -
in large application have problem:
i building window , want have example menu on left, content in middle etc.
now if want reuse of stuff (most of it) or don't want keep in 1 xaml file how do that? till used this:
- i create usercontrol + viewmodel components (usually need split main view 2 or 3 components)
in main window (xaml) put:
<dockpanel> <contentcontrol content="{binding menu}" dockpanel.dock="left"/> <contentcontrol content="{binding mainstuff}"/> </dockpanel>
in main windowviewmodel put:
menu = new menuviewmodel(); mainstuff = new mainstuffviewmodel();
and vmodels have reffer mainviewmodel rarely.
this approach not couse can't see design in main window xaml editor (sometimes can see it, don't know, visual tries binding before compilation fails, don't want think :))
what pro approach here?
do have corresponding menuview menuviewmodel?
in case can replace contentcontrol following:
<dockpanel> <prefix:menuview datacontext="{binding menu}" dockpanel.dock="left"/> <prefix:mainstuffview datacontext="{binding mainstuff}"/> </dockpanel>
this way design view of menuview- , mainstuffview-usercontrols
Comments
Post a Comment