Open Popup from Controller with Event; Close with Event?

Topics: Prism v2 - WPF 4
Sep 22, 2010 at 8:45 PM

I have a controller class that subscribes to an event, and when fired opens a view in the popup region behavior. I am passing a callback in the event payload to the view's viewmodel. However, I need to close the view after the user clicks a button.  Does it make sense to fire another event and have the controller close the popup as well? I know it'll work however I can see how my app could start to have many open/close event pairs. Maybe I could have a generic set and apply a filter to the subscription in the controller.  Does that make sense? Thanks.

Sep 23, 2010 at 2:48 PM

Hi,

There is a new recommended approach in Prism 4 for achieving this scenario, which requires the usage of  InteractionRequest and InteractionRequestTriggers. I noted that you are using Prism 2 but it might guide you. For more information on this topic:

On the other hand, if your scenario requires to close a popup after clicking a button, you could use commands. For more information, you could check the following:

I do not know your exact scenario, so take into account that Prism provides guidance for many scenario, but if you consider necessary the usage of events in your particular scenario, you could do that.

There are other forums threads where this topic has been treated, so you could take a look at the following links:

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

Sep 23, 2010 at 5:07 PM

At this point, the app is new, so I think migrating from v2 to v4 is the way.  Is there a doc on migrating? I see the MVVM RI uses MEF in lieu of Unity.  I have no love or hate toward Unity so it makes no diff to me, I just need to know where I need to make changes.  Also, this is a WPF app and the MVVM RI appears to only be Silverlight. I guess the app doesn't technically need to be WPF for migrating to Silverlight is fine as well.

Sep 23, 2010 at 6:13 PM

We are working on a migration guide for upgrading from v2 to v4, but it is still in the rough draft stage.

Prism is DI Contianer agnostic.  You can choose to use Unity or MEF with the provided code, or if you want to write a little bit of code you can use any other container you want.  So if your app is already using Unity and it fits your needs, there is no need to change to MEF.

Also, Prism provides guidance on both WPF and Silverlight.  Due to past experiences, we have written our samples on the more constrained platform (Silverlight) first, and where possible with the time constraints we have, we are porting the samples to WPF as well. In the next drop, you will see the StockTrader RI updated to use MVVM in both Silverlight and WPF. 

I hope that helps you make the key decisions you need to for your app.

 

Sep 24, 2010 at 3:43 PM

I've been using Prism since it "replaced" SCSF/CAB so I'm familiar with the container agnostic behavior. As a point of note, the use of an async programming model in the MVVM Quickstart/RI could be simplified with the use of the Reactive Extensions for .NET (Rx). Personally I love it.

Sep 24, 2010 at 4:00 PM
Edited Sep 24, 2010 at 4:03 PM

Hi,

Thanks for your feedback. I've already added a work-item for a similar post. So, you could vote this over there. If you consider that it is not exactly what you want, you could create a work-item for this particular thread.

I will include a link to this thread in the work-item. Additionally, there is more information in this thread.

Thanks again,

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

 

Sep 24, 2010 at 5:31 PM

I voted up the Rx work-item. Also, @paulousky said he was working up a doc on migrating a v2 Unity app to a v4 MEF app. From looking at the prism.chm chapter 3 entry, MEF looks like less coding is required.

Oct 1, 2010 at 4:45 PM

It appears that the InteractionRequest on works with Silverlight and not WPF. Interactions.Triggers is in System.Windows.Interactivity.dll assembly as part of the Silverlight SDK.  Can this be accomplished in WPF?

Oct 1, 2010 at 8:45 PM

Hi,

There is no guidance on this topic in Prism out-the-box. As you mentioned the behaviors framework is provided by Microsoft Expression Blend. You could find interesting the following forum thread:

In Prism the MVVM RI and QS are provided for Silverlight. But take into account that could be included some updates in the final release.

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

Oct 1, 2010 at 9:04 PM

I'm not sure how that'll work since the Interaction stuff is Silverlight only.