Muliple of the same control in a view

Topics: Conventions, Getting Started
Jul 25, 2013 at 12:18 AM

I need to show the same usercontrolview in one parent view mulitple times, associated with the same viewmodel. E.g. if i have a control for paging I want it at both the top and bottom.

When I add this to my page I'm only ever seeing one of them rendered
e.g. here's a menu that just for demo purposes I'm showing twice. MenuPanel is a viewModel
in my shell
            <ContentControl cal:View.Model="{Binding MenuPanel}"/>
            <ContentControl cal:View.Model="{Binding MenuPanel}"/>
Jul 25, 2013 at 3:04 PM
The default implementation of Screen and Conductor implements IViewAware and provides view caching, this means that the same view-model will receive the same view object every time a view is resolved.
In WPF/SL/etc. the visual tree does not allow the same node to be present in multiple places, and if you try to place the same UI element in multiple places, in the best case the control is rendered once.

If you need to display the same view in multiple places, you need to disable view caching for the specific view-model by setting the protected property CacheViews to false (or globally, setting ViewAware.CacheViewsByDefault to false).