开发者

Should I change controls visibility or create different views for my login screen?

I'm working on a project which uses PRISM 4 and the MVVM pattern.

The project requires that a login screen appears at start-up, allowing users to login and, in the event that the login is successful, select a project from a list. That selection could be done within the boundaries of the Login window, but all controls would need to be replaced.

I created the Login screen as a Window which is displayed in the Shell's constructor. This allows me to display it prior to the Shell while still making the Shell the main window of the application.

The problem is that I need to display the Project selection controls within the Login window and I'm not sure exactly how I should go about hiding controls / displaying new ones within a view while still using the MVVM and PRISM guidelines.

Another solution would be to have two shells, one of them being used to display two different views (i.e.: the Login and Project selection views) while the other would be the "Main" shell of the application.

If I decide to use two shells, both the Login and Project selection screens would be separated in two views and I will not have to toy around with controls visibility. But then again, I'm not sure how exactly to imp开发者_JS百科lement that.

How would you recommend that I proceed ?


It is recommended to display the Login Dialog before the Shell is initialized. Therefor you need to create a new Window that displays the Login Dialog in the InitializeShell method of the Bootstrapper. If the user login is successful, you initialize the Shell, otherwise you kill the process. This is the reommended way because your UI (Shell) might differ from user to user (saved UI settings, different access rights,...).

For the "project selection view", I would suggest to create a dialog which is called in the ShellViewModel (via a Loaded Behavior) when the Shell is loaded successfully. Then the user can select a project right after login.


I actually just created another "Login" shell which is displayed prior to the "Main" shell.

The "Login" shell now hosts the "Credentials Input" and "Project Selection" views. The user can navigate from the "Credentials Input" View to the "Project Selection" View if his credentials are valid.

Likewise, the user may go back to the "Credentials Input" View from within the "Project Selection" View using the Navigation Journal functionality in PRISM.

Following a Project Selection, the "Login Shell" is hidden and the "Main" Shell is displayed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜