C# Prism登录对话框
我使用Prism作为应用程序,需要一个登录对话框。为了验证登录,我需要初始化Prism/MEF加载的一些应用程序数据,这样我就无法将其放入App.xmal.cs中 启动时,我将登录对话框放在引导程序的初始设置中,如下所示C# Prism登录对话框,c#,wpf,prism,C#,Wpf,Prism,我使用Prism作为应用程序,需要一个登录对话框。为了验证登录,我需要初始化Prism/MEF加载的一些应用程序数据,这样我就无法将其放入App.xmal.cs中 启动时,我将登录对话框放在引导程序的初始设置中,如下所示 protected override void InitializeShell() { Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
protected override void InitializeShell()
{
Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
//// Authenticate the current user and set the default principal
LoginDialog auth = new LoginDialog();
auth.WindowStartupLocation = WindowStartupLocation.CenterScreen;
bool? dialogResult = auth.ShowDialog();
// deal with the results
if (dialogResult.HasValue && dialogResult.Value)
{
base.InitializeShell();
Application.Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
}
else
{
Application.Current.Shutdown(-1);
}
#if SILVERLIGHT
Application.Current.RootVisual = (Shell)this.Shell;
#else
Application.Current.MainWindow = (Shell)this.Shell;
Application.Current.MainWindow.Show();
#endif
}
我很难评估是否存在任何陷阱或缺陷,任何人都有意见是的,我遇到了完全相同的困境。您只有一个RootVisual,但必须强制用户登录。这是一种常见的情况,但并未真正解决 以下是我所做的:
Initialize()
中编写代码以调用您的登录过程,在我的情况下,这就是SecurityService
RegionPopupManager
(StockTrader RI项目中与PRISM捆绑的示例)来显示模式弹出交互感谢上帝的评论。当我在做一个桌面应用程序时,我现在会坚持我的解决方案,但有时间我会试试你的。谢谢