public override void Show(object vm) { if (currentVM == vm) { return; } currentVM = vm; var view = EasyManager.GetView(vm); var control = view as UserControl; if (control == null) { return; } control.Loaded += Control_Loaded; control.Tag = vm; MainWindow.Instance.SetContent(control); }
public App() { //异常捕获 AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; //多语言初始化 string appDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string path = Path.Combine(appDir, "Assets\\Languages"); LanService.Init(new JsonDB(path), true, "zh"); //mvvm初始化 IocContainer container = new IocContainer(); container .Singleton <LocalServer>() .Singleton <WallpapersViewModel>() .Singleton <SettingViewModel>() .Singleton <AppMenuViewModel>(); Inputs = GetInputs(); AppManager appManager = new AppManager(); if (Inputs.ContainsKey("wallpaper")) { string saveDir = Inputs["wallpaper"]; SetSaveDir(appManager, saveDir); } container.Instance(appManager); EasyManager.Initialize(container, new StoreNavigator()); EasyManager.Associate <WallpapersView, WallpapersViewModel>(); EasyManager.Associate <SettingView, SettingViewModel>(); }