Example #1
0
        public UIElement Init(XFrame rootFrame, XViewModel rootViewModel, bool isRoot)
        {
            RootViewModel = rootViewModel;

            var rootPage = _viewResolver.ResolvePageType(rootViewModel);

            if (rootPage == null)
            {
                throw new InvalidOperationException("Could not resolve the inital views");
            }

            UIElement rootElement = _configureNavigation(rootFrame, rootPage, isRoot);

            rootFrame.Init();

            if (isRoot)
            {
                _dispatcher.Invoke(() => rootFrame.NavigateTo(rootViewModel));
            }

            return(rootElement);
        }
        async void _navigationForward()
        {
            var vm = _xNavigation.CurrentContentObject;

            var currentPage = _rootElement.Content as XPage;

            if (currentPage != null && currentPage.DataContext != null && currentPage.DataContext == vm)
            {
                //This page is already correct (probably an out of XCore back)
                return;
            }

            var p = _viewResolver.ResolvePageType(vm);

            if (p == null)
            {
                throw new Exception("View type not implemented");
            }

            _rootElement.Navigate(p, _xNavigation.CurrentContentObject);



            if (currentPage != null &&
                !_xNavigation.NavigationHistory.Contains(currentPage.DataContext) &&
                _rootElement.BackStack.Any(_ => _.Parameter == currentPage.DataContext)
                )
            {
                var itemsToRemove = _rootElement.BackStack.Where(_ => _.Parameter == currentPage.DataContext);
                foreach (var item in itemsToRemove)
                {
                    _rootElement.BackStack.Remove(item);
                }
            }
            _updateSystemButton();
        }