Simulate Modal Window

Topics: Prism v4 - WPF 4
Oct 15, 2010 at 8:20 PM

This is for WPF.

I have so many thoughts and ideas swimming around my head that I think this answer might be simple but I just can't put it all together at the moment so I'm sorry if I'm asking a stupid question.  I want to simulate a Modal Window through the use of a covering partial opacity rectangle and usecontrol.  I have my Shell window which houses a Tab control as a Region and I want to have another region...."ModalRegion" that would have the covering rectangle and contentcontrol.  I then have a "screen conductor" that handles requests to add views to regions and it does not know about my ShellViewModel.  I want to be able to do a modalRegion.Add(dialogView) and at that point have the covering rectangle and dialog become visible.  Then on removing the view from the modal region the rectangle would get hidden.  I know how to do all this if my ShellViewModel was handling the requests but I'm struggling with doing it all via region.adds and somehow triggering the showing of the covering rectangle in the ShellView based on a view being added to the modalregion.

Looking for functionality similar to Silverlight ChildWindow using regions.

Oct 19, 2010 at 10:06 PM


In the Stock Trader RI there is an implementation of this (one for Silverligth and other for WPF). The main difference between these two implementations is the control that they are displaying.

The Reference Implementation uses the RegionPopupBehavior for managing this and it is creating the PopupDialogActivationBehavior (Silverlight) and the WindowsDialogActivationBehavior (WPF). Therefore, you could to create your own implementation of DialogActivationBehavior for achieving your scenario.

For more information on this topic, you could take a look at the following code files:

  • StockTraderRI_Desktop\StockTraderRI.Infrastructure\Behaviors\RegionPopupBehavior.cs
  • StockTraderRI\StockTraderRI.Infrastructure\Behaviors\PopupDialogActivationBehavior.cs
  • StockTraderRI_Desktop\StockTraderRI.Infrastructure\Behaviors\WindowsDialogActivationBehavior.cs

Hope this helps.

Fernando Antivero