I have a prism application containing Shell.xaml (with MainRegion), ShellViewModel.cs.
This shell window opens when the application starts. Now I want to open a second popup containing the same shell window (Shell.xaml, ShellViewModel).
A shell is defined as an example of the StockTraderRI prism. Shell.xaml contains MainRegion (a very simplified source):
<Window x:Class="Bsoft.Test.Shell" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:cal="http://www.codeplex.com/CompositeWPF" Title="MainWindow" Height="550" Width="825"> <Grid> <ContentControl cal:RegionManager.RegionName="MainRegion"/> </Grid> </Window>
The code behind contains only the base ViewModel link:
namespace Bsoft.Test.bmedApp { [Export] public partial class Shell : Window { [ImportingConstructor] public Shell() { InitializeComponent(); } [Import] ShellViewModel ViewModel { set { this.DataContext = value; } } } }
ShellViewModel is automatically installed by the MEF loader:
namespace Bsoft.Test.bmedApp { [Export] public class ShellViewModel : NotificationObject { [ImportingConstructor] public ShellViewModel() { } } }
This works as intended.
Now I want to open the shell window a second time as a popup. It is easy to see that Shell and ViewModel are not shared with:
[PartCreationPolicy(CreationPolicy.NonShared)]
But my problems are:
1) I load another view (models) in MainRegion. How do I tell the program whether the View (Model) should be loaded into the main Shell MainRegion main file or into the MainRegion popup? I think I need RegionManagers cloud managers, but I did not understand how to use them for this.
2) I have some events (EventAggregator) for views loaded in the region, for sending notifications and commands (status update, closing the view, errors) for the Shell report. How can I separate the main shell events from the popup window events (since they are both the same shell)?
I want to be able to open several pop-ups, so itβs not enough for me to use different names of the regions, I need more separation. Maybe there is a way to create a separate internal prism / fur / area / container infrastructure?