views:

332

answers:

1

Good Day,

I'm trying to get up to speed with PRISM and how it works with Silverlight/WPF. Is it possible to using DelegateCommands to open a new popup (Silverlight Window). If so, how would I go about doing something like this.

Most of the samples I've seen so far involve using DelegateCommands to retrieve data (or some other similar action).

If anyone has any suggestions, I'd appreciate it.

TIA,

coson

+4  A: 

I use the delegate command to essentially execute a method and/or pass data back to the ViewModel.

A popup, is a presentation facility, so I don't see anything wrong with adding an event handler to a button and loading up a popup from codebehind. I would suggest a more infrastructure/reusable approach by either creating some sort of IDialogService or instantiating your popups ViewModel/View and exposing the View via view injection or binding to a content control.

Jeremiah Morrill
+1 for the IDialogService. You should also use some kind of ServiceLocator, so you can define different services depending on whether you're running unit tests or really running the application.
Thomas Levesque
This is the way to go here, for sure. As for the service locator, use the one utilized by Prism (Microsoft.Practices.ServiceLocation.ServiceLocator.Current).
Anderson Imes
I later found something online that uses the IDialogService interface to do exactly what you suggested. It was an interesting solution to this type of problem. Thanks!
coson

related questions