Window dialog activation

Topics: Prism v2 - WPF 3.5
Sep 9, 2009 at 6:09 PM

Hi,

I've implemented the window region adapter from the RI and modified it to open a new window per view.  The app it's implemented in offers the user the ability to open one or more dialogs at a time and the newest window does open on top of previous ones.  As expected the user can click on any of the previous windows it will move to the top above the others (standard window behavior).  If the user attempts to re-open one of the previously opened windows from the app I "Activate" the orginally opened window but if it's buried beneath other windows it doesn't return to the top so it appears that nothing happened.  How/what do I modify to force the re-selected window to return to the top?

Thanks,

Glenn

Sep 10, 2009 at 9:32 PM

Hi Glenn,

Although I do not know the exact implementation of your region adapter as it was modified, you might get it to work by using the Focus method of the Window created by the WindowWrapper.

If the above is not helpful, please provide a small sample application with multiple popups available that uses your region adapter so we can try to reproduce and solve this issue.

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman

Sep 16, 2009 at 2:43 PM

Hi Damian,

I tried tracing code to figure out where to use Focus and wasn't able to figure it out.  I've created a sample app that demonstrates the problem.  When you run it there's text in the main window that details the steps to follow.  But I can't figure out how to attach it to this posting.  Instructions please??

Thanks!

Glenn

Sep 17, 2009 at 9:07 PM

Hi Glenn,

I think there is no way (I have not found one at least) to attach files to threads. You can upload your application to a public Skydrive folder and provide the link to the download in the thread so it can be downloaded.

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman

 

Sep 17, 2009 at 9:38 PM

Hi Damian,

Ok, we'll try that...let me know if this works.

Glenn

http://cid-b0b15ff4596667eb.skydrive.live.com/browse.aspx/.Public

Oct 1, 2009 at 6:09 PM

Damian,

Were you able to get this to download?  Any status to report?

 

Glenn

Oct 1, 2009 at 7:29 PM

Hi Glenn,

Sorry I did not get back to you before, I have been a little on the run the last couple of weeks. I was able to download the source code and created a working sample.

You can download it from here.

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman

Oct 1, 2009 at 7:31 PM

Thanks Damian,

I'll check it out now.

Glenn

Oct 1, 2009 at 9:01 PM

It works perfectly.

Thanks for all the help Damian!

 

Glenn

Oct 5, 2009 at 6:56 PM

Hi Damian,

I think I found a bug that originates from the original code from the postings about how to open multiple dialog boxes (as opposed to the shared/reused dialogbox in the Reference Implementation).  It can best be demonstrated in the sample code you sent back to me by clicking "Show Button 1 Window", then closing the button 1 stuff window, then clicking "Show Button 1 Window" again.  You should get a null reference exception in the Views_CollectionChanged event in DialogActivationBehavior.cs on the statement "this.contentDialogs.ForEach(w => this.Region.Deactivate(w.Content));" because w.Content is null.  It seems that whenever a dialogbox is closed the view contained in it is destroyed but nothing ever removes the window from the contentDialogs collection.  I think this is solved by adding "this.contentDialogs.Remove(contentDialog);" to the end of the CloseContentDialog method as in:

  private void CloseContentDialog(IWindow contentDialog)
        {
            if (contentDialog != null)
            {
                contentDialog.Closed -= this.ContentDialogClosed;
                contentDialog.Close();
                contentDialog.Content = null;
                contentDialog.Owner = null;
                this.contentDialogs.Remove(contentDialog);  // <==== add this line
            }
        }

 Can you confirm if my code change is the appropriate one? 

Thanks,

Glenn