Close dialog window design suggestions

Oct 30, 2009 at 10:25 PM

Hi all,

I'm using prism in my current Silverlight application and I need to add a generic way to implement windows management. I read about how to create a PopupDialogWindow (by adding a PopupDialogActivationBehavior and creating a wrapper around my view) and this works just fine (just for the record I use a docking component to create floating windows - but this is not the problem).

In the samples that I've seen so far this popup window is closed only using the wrapper close button and handling the event in the behavior to remove the view. I would like to have some suggestion regarding:

1. how can I close the window from the ViewModel? Should I call Close() on the View? (usually a View is added and removed from a region - I don't know how to bring in the close concept)
2. how can I notify the owner (ViewModel) of the window giving that the user can close the window from both the wrapper (close button) and the ViewModel of the window? Should the owner of the window subscribe to events of the View or the ViewModel?

I don't even know if I was able to make it clear, but I'll wait for some answers or some links to read and have a better understanding.

Thanks,

Jimmi

Nov 4, 2009 at 5:53 PM

Hi,

If you are using the popup implementation of the RI and you want to close a popup view, you can deactivate the view from the region. A possible approach to do this could be having a command in your ViewModel that executes the following actions:

  1. Gets the popup Region from the RegionManger.
  2. Obtains the view by name(calling the GetView method)
  3. Calls the Deactivate method by passing the View object as parameter.

I hope you can find this answer helpful.

Fernando Antivero
http://blogs.southworks.net/fantivero