Show the same view in two places at the same time? One in fullscreen handled by conductor and one in dialog?

Topics: UI Architecture
Oct 11, 2013 at 1:11 PM
Edited Oct 11, 2013 at 8:06 PM
EDIT: Sorry forgot to mention I'm working in Silverlight

I am trying to make a dialog called PrintPreview. The PrintPreviewView is a UserControl intended to host the view to be printed and provide buttons to print or cancel. I want to be able to choose between the default view or another view specified by the view context (like a custom made printview) so I use the cal:View.Context on a ContentControl and binds it to the viewModel. Here is the code to host the view:
<ContentControl x:Name="HostedView" cal:View.Context="{Binding ViewContext}"/>
I bring out this printpreview with WindowManager.ShowDialog() when the user presses the print button on a View. A major problem appears when ViewContext is null (default view). Then the real view (partially covered by the printpreview dialog) disappears! It is correctly shown in the printpreview dialog but I want it to also remain behind the dialog so the user can continue to work after the dialog is closed. At the moment it can only be brought back by navigating away and then back to the screen, causing ChangeActiveItem to run on my conductor (Collection.OneActive).

This is the ViewModel constructor:
    public PrintPreviewViewModel(IToolbarDelegate printView, string viewContext = null)
        DisplayName = "Förhandsgranska utskrift";
        HostedView = printView;
        _viewContext = viewContext;
and I bring out the printpreview dialog like this from any viewModel that I want to be printable:
_windowManager.ShowDialog(new PrintPreviewViewModel(this)); //default view
_windowManager.ShowDialog(new PrintPreviewViewModel(this, "PrintView")); // Use another view that's custom made for printing
Is there any way to keep the view in the conductor behind the dialog as well? Do I need to clone the viewModel and send in the clone to my PrintPreviewViewModel or will it help if the PrintPreviewViewModel is a conductor?
Oct 12, 2013 at 9:17 AM
Problem solved!

I actually had more problems than I first realized. Even when displaying another view of the same viewmodel, the default view behind the dialog would disappear. This problem was solved by setting a Fallbackvalue on the binding:
<ContentControl x:Name="HostedView" cal:View.Context="{Binding ViewContext, FallbackValue=---}"/>
I guess the binding would initialize to null causing the defualt view to be removed? Anyway, after this I could display specialized views of the same VM without problems.

To display the default view both on the main screen and in the dialog at the same time I had to set CacheView = false; on that view. My bad here, didn't search the discussions in the right words until after I had formulated this thread.