WindowRegionAdapter- ShowDialog()

Feb 4, 2009 at 3:31 AM
Hello,

I attempted today to use the WindowRegionAdapter however it seems it does not support Modal Windows. It appears to useWindow.Show() when launching the new window. Has anyone had any luck launching a Modal dialog with this adapter?

Brette
Feb 24, 2009 at 8:06 PM
I'm attempting the same. At first, I just created some dialogs and developed them outside of the Composite WPF architecture that the rest of the application is using. Then I thought, I should check to see if there's a way to create these dialogs as modules. So, I came across the WindowRegionAdapter, however, I also need these dialogs to be modal.

I downloaded the sample application for the WindowRegionAdapter here, http://blogs.southworks.net/ibaumann/2008/09/26/windowregionadapter-for-compositewpf-prism/ and changed the window.Show() (in the adapter) to window.ShowDialog()

The problem comes about when you close the dialog.

An exception is generated when the region attempts to remove the content in the Closed event handler for the window.
The specific exception is: "Cannot change ObservableCollection during a CollectionChanged event."
Also, I started working on integrating it into my project by noticed that the RegionAdapterBase doesn't have a 0 parameter ctor as is called using the version of CAL that's in the example for the Adapter (it takes a IRegionBehaviorFactory as the sole parameter). 

Has anyone atttempted to get this working with the final release of 2.0 version, and possibly even working for modal dialogs?
Thanks for any help

private void window_Closed(object sender, EventArgs e)
{
    Window window = sender as Window;
    IRegion region = _regionWeakReference.Target as IRegion;
    if (window != null && region != null)
    if (region.Views.Contains(window.Content))
        region.Remove(window.Content);        // exception occurs here
}






Jan 13, 2010 at 10:25 AM

I ran into the same problem , I changed the window_Closed method and executed the region.Remove(window.Content); in ThreadPool.QueueUserWorkItem you can find the whole code in my blog

http://www.biztalkand.net/blog/post/Closing-window-with-WindowRegionAdapter.aspx

Enrique Gonzalez.