コード例 #1
0
        protected override void Configure()
        {
            //异常捕获
            Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
            AppDomain.CurrentDomain.UnhandledException       += CurrentDomain_UnhandledException;

            //映射公用库中的vm
            string dzyView      = "DZY.DotNetUtil.WPF.Views";
            string dzyViewModel = "DZY.DotNetUtil.WPF.ViewModels";

            ViewLocator.AddSubNamespaceMapping(dzyViewModel, dzyView, "Control");
            ViewModelLocator.AddSubNamespaceMapping(dzyView, dzyViewModel);

            //初始化ioc容器
            container = new SimpleContainer();

            container.
            Singleton <IEventAggregator, EventAggregator>().
            Singleton <IWindowManager, WindowManager>().
            Singleton <CountDownViewModel>().
            Singleton <ContextMenuViewModel>(nameof(ContextMenuViewModel)).
            Singleton <EyeNurseService>().
            PerRequest <LockScreenViewModel>().
            PerRequest <SettingViewModel>().
            Instance(container);
        }
コード例 #2
0
        /// <summary>
        /// Change mapping locator between view & viewmodel.
        /// </summary>
        private void ChangeMappingLocator()
        {
            // configure view & viewmodel locator.
            var config = new TypeMappingConfiguration
            {
                DefaultSubNamespaceForViews      = "BookManagement.View",
                DefaultSubNamespaceForViewModels = "BookManagement.ViewModel"
            };

            Caliburn.Micro.ViewLocator.ConfigureTypeMappings(config);
            ViewModelLocator.AddSubNamespaceMapping("BookManagement.ViewModel", "BookManagement.View");
        }