Login dialog in PRISM + WPF

Topics: Prism v4 - WPF 4
May 25, 2011 at 12:16 PM

Hi,
I am trying to implement a login dialog in PRISM WPF app. 
I implemented the dialog with a region in the Shell by using the RegionPopupBehavior (from the Stocktrader sample app), then I show the dialog navigating to the view, but when the login is complete, how can i hide or remove that dialog?


What is the best approach to do this operations? by using Navigation, Interaction Requests...?

Jose.

Developer
May 26, 2011 at 3:06 PM

Hi Jose,

You could use the approach described in this thread to close a popup, which basically involves removing the view from the popup region.

Another alternative would be to subscribe to an event (with the event aggregator) in your login dialog view, and call the Close method in the handler. Then, you could publish that event when you have logged in. That approach could be helpful if you want to perform more operations when you are logged in (by subscribing to that event in the involved controllers). You could also combine both of them, and call the Region.Remove method in the handler for that event subscription in a controller or view model.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

May 26, 2011 at 3:19 PM

Hi Guido,

I was looking on how to accomplish this same task.  Can you create a repo sample for us using the event aggregator you describe above?  That would help me out on a project that I am currently working on.  Talk to you soon.

Regards,

John

May 26, 2011 at 3:26 PM

Hi Guido,

Thanks for reply. I will try the event subscription, seems to be the most appropriate approach to my code.

Jose

May 26, 2011 at 3:51 PM

Hi Guido,

I'm am very interested on the a repo sample for the event aggregator.  Can you post one when you have a few minutes?  Thanks.

Regards,

John

Developer
May 26, 2011 at 5:58 PM

Hi John, Jose,

I've created a repro sample that illustrates the idea of using the Event Aggregator to communicate the event of a user logging in, along with the closing of a popup window in response to that event.

You can download the sample here.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

May 26, 2011 at 6:34 PM

Thanks Guido,

Really nice sample.

Regards,

John

May 26, 2011 at 9:03 PM

Thanks for the sample Guido, has been very useful.

Jose