Prism + login page

Topics: Prism v2 - Silverlight 3
Feb 11, 2010 at 7:15 AM

Hello guys

I am working application using prism with silverlight,i am unable to show the login page before Shell (or) BootStrapper,

my Requirement is before Shell load or BootStrapper run  to show login page ,i am checking credential in login page onecs credential is valid then shell should be load

this the code i writen in App.xmal page

<font face="Consolas" size="2" color="#0000ff"><font face="Consolas" size="2" color="#0000ff"><font face="Consolas" size="2" color="#0000ff">

private

</font></font></font>
<font face="Consolas" size="2" color="#0000ff"><font face="Consolas" size="2" color="#0000ff">

 

</font></font>
<font face="Consolas" size="2" color="#0000ff">

 

</font>

 

<font face="Consolas" size="2" color="#0000ff"><font face="Consolas" size="2" color="#0000ff">

 

</font></font>
<font face="Consolas" size="2" color="#0000ff">

 

</font>

 

<font face="Consolas" size="2" color="#0000ff">

 

</font>

 

void Application_Startup(object sender, StartupEventArgs e)

{

this.RootVisual = new Login();

}

 

 private void btnLogin_Click(object sender, RoutedEventArgs e)

{

            Csla.DataPortal.ProxyTypeName = typeof(Csla.DataPortalClient.SynchronizedWcfProxy<>).AssemblyQualifiedName;
            Bootstrapper bootstrapper = new Bootstrapper();
            bootstrapper.Run();

}

Feb 11, 2010 at 8:06 PM

Hi,

As this article from the MSDN documentation explains, “You can set the value of the RootVisual property only one time from code, although you get its value any number of times.” Therefore, if you set the RootVisual to be an instance of Login, the Bootstrapper’s functionality can never set the Shell to be the RootVisual, thus the Shell won’t be displayed.

You can read about a possible workaround for this situation in this thread.

Please let me know if this helps.

Damian Schenkelman
http://blogs.southworks.net/dschenkelman

 

Feb 16, 2010 at 12:14 AM

I'm trying to get this to work with a WPF application without success. I open the Login Dialog from within Application.Xaml.vb and upon return from the dialog I run the Bootstrapper. In the CreateShell the View.Show command just results in the application exiting and no shell being viewed. There has to be a way for an application to authorize the user before the Prism bootstrapping process but I can't find it. If anyone has any answers, please share.

Feb 16, 2010 at 12:23 PM

Here is what I do.  Note the calls to change the ShutDownMode.....

   protected override void OnStartup(StartupEventArgs e)
        {
            Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;

            // Authenticate the current user and set the default principal
            AuthenticationSplashScreen auth = new AuthenticationSplashScreen();
            auth.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            bool? dialogResult = auth.ShowDialog();

            // deal with the results
            if (dialogResult.HasValue && dialogResult.Value)
            {
                AppDomain.CurrentDomain.SetThreadPrincipal(auth.NewPrincipal);
                base.OnStartup(e);
            }
            else
            {
                this.Shutdown(-1);
            }

            this.ShutdownMode = ShutdownMode.OnMainWindowClose;

#if (DEBUG)
            RunInDebugMode();
#else
            RunInReleaseMode();
#endif
        }
Feb 16, 2010 at 4:26 PM

Thank you for the help!