Exemplo n.º 1
0
        public async Task NavigateToAsync <TViewModel>(NavigateParameters navigateParameters)
            where TViewModel : IMdiWindowViewModel, INavigateAware
        {
            var viewModel = FindOrCreateViewModel <TViewModel>(navigateParameters);

            _windowManager.ActivateWindow(viewModel);
            viewModel.NavigatedTo(navigateParameters?.Context);
            await viewModel.InitAsync();
        }
Exemplo n.º 2
0
        public async Task NavigateToAsync <TViewModel>(string key, object obj)
            where TViewModel : IMdiWindowViewModel, INavigateAware
        {
            ViewModelContext context = new ViewModelContext();

            context.AddValue(key, obj);
            NavigateParameters navigateParameters = new NavigateParameters(context);

            await NavigateToAsync <TViewModel>(navigateParameters);
        }
Exemplo n.º 3
0
        public async Task NavigateToAsync <TViewModel>(NavigateParameters navigateParameters, Action <NavigationResult> navigationCallback)
            where TViewModel : IMdiWindowViewModel, INavigateAware
        {
            if (navigationCallback == null)
            {
                throw new ArgumentNullException(nameof(navigationCallback));
            }

            var viewModel = FindOrCreateViewModel <TViewModel>(navigateParameters);

            viewModel.CallBackAction = navigationCallback;
            _windowManager.ActivateWindow(viewModel);
            viewModel.NavigatedTo(navigateParameters?.Context);
            await viewModel.InitAsync();
        }
Exemplo n.º 4
0
        private TViewModel FindOrCreateViewModel <TViewModel>(NavigateParameters navigateParameters)
            where TViewModel : IMdiWindowViewModel, INavigateAware
        {
            TViewModel viewModel;

            if (navigateParameters != null && navigateParameters.GuidWindows != Guid.Empty)
            {
                viewModel = _windowManager.FindWindow <TViewModel>(navigateParameters.GuidWindows);
                if (viewModel == null)
                {
                    throw new ArgumentNullException(nameof(viewModel));
                }
            }
            else
            {
                viewModel = _windowsFactory.CreateWindow <TViewModel>();
                Guid containerGuid = navigateParameters == null ? Guid.Empty : navigateParameters.GuidContainer;
                viewModel = _windowManager.AppendWindowWithoutInit(viewModel, containerGuid, false);
            }
            return(viewModel);
        }