private bool Navigate(IPageViewModel pageViewModel)
        {
            object page;

            if (pages.TryGetValue(pageViewModel, out page))
            {
                CurrentPage.Navigation.PushAsync((Page)page);
                return(true);
            }

            string viewModel = pageViewModel.GetType().Name;
            string pageName  = viewModel.Substring(0, viewModel.IndexOf("ViewModel", StringComparison.Ordinal));

            var typeInfo = GetType().GetTypeInfo().Assembly.DefinedTypes
                           .SingleOrDefault(a => a.Name.Equals(pageName));
            var type = typeInfo.AsType();

            if (type == null)
            {
                return(false);
            }

            Page src = (Page)Activator.CreateInstance(type, pageViewModel);

            pages.Add(pageViewModel, src);
            CurrentPage.Navigation.PushAsync(src);
            CurrentPage = src;
            return(true);
        }
        public bool Navigate(IPageViewModel pageViewModel)
        {
            string viewModel = pageViewModel.GetType().Name;
            string pageName = viewModel.Substring(0, viewModel.IndexOf("ViewModel", StringComparison.Ordinal));

            var type = Assembly.GetExecutingAssembly().GetTypes().SingleOrDefault(a => a.Name.Equals(pageName));
            if (type == null) return false;

            var src = Activator.CreateInstance(type, pageViewModel);
            return frame.Navigate(src);
        }
Exemple #3
0
        private IView LocateNavigationFor(IPageViewModel viewModel)
        {
            var view           = _viewLocator.ResolveView(viewModel, "NavigationView");
            var navigationPage = view as IView;

            if (navigationPage is null)
            {
                Debug.WriteLine($"No navigation view could be located for type '{viewModel.GetType().FullName}', using the default navigation page.");
                navigationPage = new NavigationView(_mainScheduler, _backgroundScheduler, _viewLocator);
            }

            return(navigationPage);
        }
        // Изменить текущую страницу
        private void ChangeViewModel(IPageViewModel viewModel)
        {
            if (!PageViewModels.Contains(viewModel))
            {
                PageViewModels.Add(viewModel);
            }

            if (viewModel.GetType() == typeof(SignInPageViewModel) ||
                viewModel.GetType() == typeof(SignOnPageViewModel) ||
                viewModel.GetType() == typeof(ConfirmEmailViewModel) ||
                viewModel.GetType() == typeof(RefreshPasswordViewModel)
                )
            {
                IsHeaderVisible = Visibility.Hidden;
            }
            else
            {
                IsHeaderVisible = Visibility.Visible;
            }

            CurrentPageViewModel = PageViewModels.FirstOrDefault(vm => vm == viewModel);
        }
        private bool Navigate(IPageViewModel pageViewModel)
        {
            object page;

            if (pages.TryGetValue(pageViewModel, out page))
            {
                return(frame.Navigate(page));
            }

            string viewModel = pageViewModel.GetType().Name;
            string pageName  = viewModel.Substring(0, viewModel.IndexOf("ViewModel", StringComparison.Ordinal));

            var type = Assembly.GetExecutingAssembly().GetTypes().SingleOrDefault(a => a.Name.Equals(pageName));

            if (type == null)
            {
                return(false);
            }

            var src = Activator.CreateInstance(type, pageViewModel);

            pages.Add(pageViewModel, src);
            return(frame.Navigate(src));
        }