Exemple #1
0
        public void LoadService(RolodexService rolodexService, string regionName, object parameter)
        {
            if (string.IsNullOrEmpty(regionName))
            {
                regionName = Constants.MainRegion;
            }
            ServiceDefinition serviceDefinition = _services[rolodexService];

            if (!regionManager.ActivateViewIfExists(regionName, serviceDefinition.ViewInterfaceType))
            {
                regionManager.DeactivateViews(regionName);
                var viewModel = (IRolodexViewModel)unityContainer.Resolve(serviceDefinition.ViewModelInterfaceType, null);
                var view      = (IRolodexView)unityContainer.Resolve(serviceDefinition.ViewInterfaceType, null);
                regionManager.AddViewToRegion(regionName, view);
                view.DataContext = viewModel;
                regionManager.ActivateViewIfExists(regionName, serviceDefinition.ViewInterfaceType);
                if (parameter == null)
                {
                    viewModel.Initialize();
                }
                else
                {
                    viewModel.Initialize(parameter);
                }
            }
        }