Show login modal form before

Topics: Prism v2 - WPF 3.5
Jun 3, 2009 at 9:31 AM

I just start to write an application with prism and can't find answers for some questions.

1) My application shoud ask a login and a password before the main window will run. How to create and show a modal window. 

2) The application has a root menu and when I choose an element in the "MainRegion" should be shown a parent container for this element with it's own submenu. When choosse another element from the root menu - active parent container shoul be hidden or closed and another parent container must be shown instead of it. Is't possible to realize this mechanizm in Prism?

Jun 3, 2009 at 8:36 PM

Hi

 

I will try to answer your questions separately.

 

1.       There are different ways a login scenario could be implemented. For example, you could show a window with the login form at the beginning of the application, before loading all modules, and then based on the logged  user load the required modules. Another option could be performing the authentication once the application has started. In this case, setting all modules that are security enforced to load on demand could be done. You would then have a service to query for all available modules for a specific role and would load dynamically all the on demand modules available for that role.

 

If you wanted to use a “modal window” once the application has started, you might find useful the following thread.:

·         Showing a view in a region vs a modal dialog

 

In case you use the Reference Implementation option you will need to change the Show method of the WindowWrapper.Desktop class to use a modal window, like this:

public void Show()

{

      this.window.ShowDialog();

}

               

2.       If I understand correctly you want to change the view that is shown in a region based on which button is clicked on a menu. If this is the case, some links below may help you. If this is not you scenario please provide more information so I can get a better picture:

·         how to build an outlook style application – part 1

·         how to build an outlook style application with prism v2 – Part 2

·         ContentControl in MainRegion

·         Menu in a module

·         Module Navigation With MenuItem Click?   

·         Region and ContextMenu

 

Please let me know if this helps.

 

Damian Schenkelman

http://blogs.southworks.net/dschenkelman

Jun 4, 2009 at 5:33 AM

Hi, Damian!

Thank you for your answer. I'll look and try it today and let you know does it help or not. I red your blog and found some interesting for me.

Jun 4, 2009 at 1:15 PM

It's help me too much. And, as continue, I have another questions. An application has a region MainRegion

<ItemsControl Name="MainRegion"  cal:RegionManager.RegionName="{x:Static inf:RegionNames.MainRegion}"/>

When I click on the first menu element a first View addings to the region as

regionManager.Regions[RegionNames.MainRegion].Add(View1);

regionManager.Regions[RegionNames.MainRegion].Activate(View1);

1.  How to let View1 to know that it's activated. Because at this time View1 should ask a service for a getting data?

2. When I click on the second  menu element I wish to deactivate View1 and show View2. But, when I'm doing regionManager.Regions[RegionNames.MainRegion].Deactivate(View1);

the error message is "Deactivation is not possible in this type of region".

I can .Remove(View1) but it is't applicable for me, because View2 added a new user and return NewUserID to View1 that should just get information about  this user from service sending NewUserID  and information from the response into a user list, but not asking a full list again.


Jun 4, 2009 at 11:34 PM

Hi

 

If you want to have more than one view in a region, but just show one at a time you should use a ContentControl as a region. Then you will be able to activate/deactivate views in the region as you were doing. If you are using a ContentControl region, you only need to activate one view, and the one that is currently active will be deactivated automatically.

 

To know when a view is activated/deactivated you could implement the IActiveAware interface. You can read more about that in this thead:

·         Using IActiveAware

 

Please let me know if this helps.

 

Damian Schenkelman

http://blogs.southworks.net/dschenkelman

Jun 10, 2009 at 10:17 AM

Hi, Damian!

Thank you. I've created an application I wanted with your helps.

Sep 22, 2009 at 7:52 PM
dschenkelman wrote:

Hi

 

I will try to answer your questions separately.

 

1.       There are different ways a login scenario could be implemented. For example, you could show a window with the login form at the beginning of the application, before loading all modules, and then based on the logged  user load the required modules. Another option could be performing the authentication once the application has started. In this case, setting all modules that are security enforced to load on demand could be done. You would then have a service to query for all available modules for a specific role and would load dynamically all the on demand modules available for that role.

 

Damian,

  I want to show a login box and then load modules based on permissions.  I'm doing this in my SCSF/CAB app and now I'm porting it to Prism.  Would I do this in the project containing the Shell?  Would the login be a seperate module that in turn loads constituent modules?  If I do the login in a module, how can I kill the app if the use cannot log in?  Sample?  Thanks much.

Aug 19, 2010 at 2:17 AM

1.       There are different ways a login scenario could be implemented. For example, you could show a window with the login form at the beginning of the application, before loading all modules, and then based on the logged  user load the required modules. Another option could be performing the authentication once the application has started. In this case, setting all modules that are security enforced to load on demand could be done. You would then have a service to query for all available modules for a specific role and would load dynamically all the on demand modules available for that role.

 

If you wanted to use a “modal window” once the application has started, you might find useful the following thread.:

·         Showing a view in a region vs a modal dialog

 

In case you use the Reference Implementation option you will need to change the Show method of the WindowWrapper.Desktop class to use a modal window, like this:

public void Show()

{

      this.window.ShowDialog();

}

               

Hey Damian,

I have pored over the discussions and the guidance documentation over and over again, and I am still stumped as to how to use prism to accomplish the feature of loading a window for the login form at the beginning of the application. I have highlighted the sentence in your comment above. Is the suggestion to use a plain vanilla WPF window that will implement authentication before calling Run on the bootstrapper? It seems like I am something really simple if that's NOT what you meant.

Thanks

KD

Aug 19, 2010 at 9:02 PM

I'm using CredUI from Ookii.Dialogs and it works great. 

Aug 24, 2010 at 5:30 PM

Hi Kshitjid
I'm sure the intention is for the Login Dialogue to be outside of and before Prism loads. That's how I just read this thread.
So, the login dialogue connects with your security providers first and, once the requesting user is validated and the permissions known, the Shell starts and the modules can be loaded.
Which is how my original CAB one worked if I remember rightly

However, I'm reading these threads as I need my application to start up the other way round.....
In other words the Shell starts and as the user is not authorised only the login module loads. If you think of the app as like Outlook, then the only item in the left vertical OutLookBar is the login module, and the login prompt is in the Shell's main window. After authorisation the login module closes and the allowed modules load, and a "Disconnect" menu item appears in the File menu.
Now the user can log out of App1, and login into App2 without closing the Shell. (Sort of like SQL Server Management Studio).

Can anyone say whether this is plausable with Prism?

thanks
John

Aug 24, 2010 at 5:36 PM

But as Damian says, by refering us to http://compositewpf.codeplex.com/Thread/View.aspx?ThreadId=48199

Using the WindowsRegion Adapter, you could have the Shell start and the login module load in a widow outside the shell