Prism MVVM应用 登陆后切换主窗体实现

上传者: cxb2011 | 上传时间: 2021-08-23 11:35:13 | 文件大小: 406KB | 文件类型: ZIP
应用场景        使用Prism7开发WPF程序,编码采用MVVM形式。当程序启动时,首先进入一个登陆界面,进行登陆认证,认证成功后转入程序布局主窗口。 设计思路         WPF程序框架搭建后,程序中存一个Shell.xaml,相当于表演者的唯一舞台。登陆窗体(以下简称 LoginView)和程序布局主窗体(以下简称 MainView),分别利用IRegionManager进行管理,根据需要在不同时机相继出场表演。所有操作均由各自ViewModel(简称VM)代码完成。        1.当程序启动后,Shell通过VM,使用RegionManager的Add方法激活LoginView。登陆操作后,发送消息loginState消息。该消息的发送是通过一个自定义的消息发送和订阅类来完成的(程序中将定义为:LoginSentEvent)。        2.Shell通过VM接受LoginSentEven传递的loginState来接收登陆成功与否的消息,如果登陆成功,则使用RegionManager的Deactivate方法使LoginView处于非激活隐藏。利用 Add方法使MainView视图激活。如果不成功呢,当然不改变视图了,继续登陆操作。

文件下载

资源详情

[{"title":"( 66 个子文件 406KB ) Prism MVVM应用 登陆后切换主窗体实现","children":[{"title":"rzSoft","children":[{"title":"ViewModels","children":[{"title":"MainWindowViewModel.cs <span style='color:#111;'> 432B </span>","children":null,"spread":false},{"title":"ShellViewModel.cs <span style='color:#111;'> 1.87KB </span>","children":null,"spread":false},{"title":"LoginSentEvent.cs <span style='color:#111;'> 209B </span>","children":null,"spread":false},{"title":"LoginViewModel.cs <span style='color:#111;'> 799B </span>","children":null,"spread":false}],"spread":true},{"title":"packages.config <span style='color:#111;'> 534B </span>","children":null,"spread":false},{"title":"App.xaml.cs <span style='color:#111;'> 627B </span>","children":null,"spread":false},{"title":"Models","children":null,"spread":false},{"title":"Properties","children":[{"title":"Settings.settings <span style='color:#111;'> 201B </span>","children":null,"spread":false},{"title":"Resources.Designer.cs <span style='color:#111;'> 2.76KB </span>","children":null,"spread":false},{"title":"AssemblyInfo.cs <span style='color:#111;'> 2.25KB </span>","children":null,"spread":false},{"title":"Settings.Designer.cs <span style='color:#111;'> 1.07KB </span>","children":null,"spread":false},{"title":"Resources.resx <span style='color:#111;'> 5.48KB </span>","children":null,"spread":false}],"spread":true},{"title":"Service","children":null,"spread":false},{"title":"App.config <span style='color:#111;'> 189B </span>","children":null,"spread":false},{"title":"App.xaml <span style='color:#111;'> 377B </span>","children":null,"spread":false},{"title":"obj","children":[{"title":"Debug","children":[{"title":"rzSoft.exe <span style='color:#111;'> 15.00KB </span>","children":null,"spread":false},{"title":"rzSoft.csproj.GenerateResource.cache <span style='color:#111;'> 954B </span>","children":null,"spread":false},{"title":"rzSoft.g.resources <span style='color:#111;'> 5.01KB </span>","children":null,"spread":false},{"title":"rzSoft.csproj.CoreCompileInputs.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"rzSoft_MarkupCompile.i.cache <span style='color:#111;'> 266B </span>","children":null,"spread":false},{"title":"TempPE","children":null,"spread":false},{"title":"rzSoft.csproj.FileListAbsolute.txt <span style='color:#111;'> 2.07KB </span>","children":null,"spread":false},{"title":"rzSoft.Properties.Resources.resources <span style='color:#111;'> 180B </span>","children":null,"spread":false},{"title":"rzSoft.csproj.CopyComplete <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferencesInput.cache <span style='color:#111;'> 7.86KB </span>","children":null,"spread":false},{"title":"rzSoft_MarkupCompile.lref <span style='color:#111;'> 176B </span>","children":null,"spread":false},{"title":"rzSoft_MarkupCompile.i.lref <span style='color:#111;'> 122B </span>","children":null,"spread":false},{"title":"App.g.i.cs <span style='color:#111;'> 1.89KB </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferences.cache <span style='color:#111;'> 672B </span>","children":null,"spread":false},{"title":"rzSoft_MarkupCompile.cache <span style='color:#111;'> 267B </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"rzSoft.csprojAssemblyReference.cache <span style='color:#111;'> 70.48KB </span>","children":null,"spread":false},{"title":"rzSoft.pdb <span style='color:#111;'> 55.50KB </span>","children":null,"spread":false},{"title":"Views","children":[{"title":"Login.g.i.cs <span style='color:#111;'> 3.15KB </span>","children":null,"spread":false},{"title":"LoginView.g.i.cs <span style='color:#111;'> 3.00KB </span>","children":null,"spread":false},{"title":"Login.g.cs <span style='color:#111;'> 3.15KB </span>","children":null,"spread":false},{"title":"MainWindow.g.cs <span style='color:#111;'> 3.17KB </span>","children":null,"spread":false},{"title":"Login.baml <span style='color:#111;'> 1.34KB </span>","children":null,"spread":false},{"title":"Shell.g.cs <span style='color:#111;'> 3.17KB </span>","children":null,"spread":false},{"title":"Shell.baml <span style='color:#111;'> 2.02KB </span>","children":null,"spread":false},{"title":"Shell.g.i.cs <span style='color:#111;'> 3.17KB </span>","children":null,"spread":false},{"title":"MainWindow.baml <span style='color:#111;'> 1.32KB </span>","children":null,"spread":false},{"title":"MainWindow.g.i.cs <span style='color:#111;'> 3.17KB </span>","children":null,"spread":false}],"spread":false},{"title":"App.g.cs <span style='color:#111;'> 1.89KB </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"rzSoft.csproj <span style='color:#111;'> 6.69KB </span>","children":null,"spread":false},{"title":"bin","children":[{"title":"Debug","children":[{"title":"Prism.Unity.Wpf.dll <span style='color:#111;'> 28.38KB </span>","children":null,"spread":false},{"title":"rzSoft.exe <span style='color:#111;'> 15.00KB </span>","children":null,"spread":false},{"title":"System.Windows.Interactivity.dll <span style='color:#111;'> 54.59KB </span>","children":null,"spread":false},{"title":"rzSoft.exe.config <span style='color:#111;'> 189B </span>","children":null,"spread":false},{"title":"Prism.Wpf.pdb <span style='color:#111;'> 52.30KB </span>","children":null,"spread":false},{"title":"CommonServiceLocator.dll <span style='color:#111;'> 10.00KB </span>","children":null,"spread":false},{"title":"Prism.pdb <span style='color:#111;'> 247.50KB </span>","children":null,"spread":false},{"title":"Prism.Wpf.xml <span style='color:#111;'> 275.47KB </span>","children":null,"spread":false},{"title":"Unity.Container.dll <span style='color:#111;'> 100.00KB </span>","children":null,"spread":false},{"title":"Unity.Abstractions.dll <span style='color:#111;'> 77.50KB </span>","children":null,"spread":false},{"title":"Prism.xml <span style='color:#111;'> 147.24KB </span>","children":null,"spread":false},{"title":"Prism.Wpf.dll <span style='color:#111;'> 134.88KB </span>","children":null,"spread":false},{"title":"Prism.Unity.Wpf.pdb <span style='color:#111;'> 5.03KB </span>","children":null,"spread":false},{"title":"Prism.Unity.Wpf.xml <span style='color:#111;'> 17.59KB </span>","children":null,"spread":false},{"title":"rzSoft.pdb <span style='color:#111;'> 55.50KB </span>","children":null,"spread":false},{"title":"Prism.dll <span style='color:#111;'> 70.38KB </span>","children":null,"spread":false}],"spread":false},{"title":"Release","children":null,"spread":false}],"spread":true},{"title":"Views","children":[{"title":"Login.xaml <span style='color:#111;'> 844B </span>","children":null,"spread":false},{"title":"MainWindow.xaml.cs <span style='color:#111;'> 629B </span>","children":null,"spread":false},{"title":"MainWindow.xaml <span style='color:#111;'> 710B </span>","children":null,"spread":false},{"title":"Shell.xaml <span style='color:#111;'> 1008B </span>","children":null,"spread":false},{"title":"Shell.xaml.cs <span style='color:#111;'> 609B </span>","children":null,"spread":false},{"title":"Login.xaml.cs <span style='color:#111;'> 648B </span>","children":null,"spread":false}],"spread":true}],"spread":false}],"spread":true}]

评论信息

  • HenryMoore :
    这种不太合理,登录用户控件和主用户控件都放shell里,一般登录窗体和主窗体标题栏或者整体样式都不同的,该样例适合演示region切换
    2021-01-03
  • fireghost57 :
    不错,学习了
    2019-09-22

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明