WPF PRISM - Display multiple pop-up view on the same time

1k views Asked by At

My Shell Window contains a secondary pop-up region from the Stock Trader RI demo application

infBehaviors:RegionPopupBehaviors.CreatePopupRegionWithName="{x:Static inf:RegionNames.SecondaryRegion}"

I am activating my views using the regionManager's RequestNavigate method:

regionManager.RequestNavigate(RegionNames.SecondaryRegion, new Uri(FooView, UriKind.Relative));

Everything works fine if I work just with a single View. However in my case I want to have multiple Pop-up Windows at once - like having multiple pop-up regions at once. It seems that the problem lies in the activation/deactivation of the views inside the region.

How to "persuade" not to deactivate my previous view inside the region?

Any idea?

2

There are 2 answers

2
Sebastjan On BEST ANSWER

It turned out that the solution is easier than I expected. Here is the solution in case if enybody needs it.

I just had to modify the RegionPopupBehaviours to use AllActiveregion instead of the original SingleActiveRegion and in the DialogActivation I had to remove the first call to the CloseContentDialog.

Hope that is helps.

0
Aaron On

I came across this issue and I thought I would expand on @Sebastjan's post since it might help someone down the road.

Using the code from the Stock Trader RI demo, in the RegionPopupBehaviors class, the RegisterNewPopupRegion method should look like this:

public static void RegisterNewPopupRegion(DependencyObject owner, string regionName)
    {
        IRegionManager regionManager = ServiceLocator.Current.GetInstance<IRegionManager>();
        if (regionManager != null)
        {
            IRegion region = new AllActiveRegion(); //This was changed from SingleActiveRegion
            DialogActivationBehavior behavior;
            behavior = new WindowDialogActivationBehavior();
            behavior.HostControl = owner;

            region.Behaviors.Add(DialogActivationBehavior.BehaviorKey, behavior);
            regionManager.Regions.Add(regionName, region);
        }
    }

For anyone that doesn't have the code sample for the stock trader app, you can find it here