Ejemplo n.º 1
0
        private void Initialize()
        {
            ConfigureMainView();

            _navigationManager.AddRegionIfMissing(NormalRegion, RegionHeader);

            INavigationRegion normalRegion = _navigationManager.Regions[NormalRegion];

            normalRegion.Add(
                new NavigationDescriptor()
            {
                ViewName     = "WidgetView",
                Header       = "主 页",
                ViewResolver = () => _container.Resolve <DefaultWidgetPanel>()
            });

            normalRegion.Add(
                new NavigationDescriptor()
            {
                ViewName     = "UserProfileManagementView",
                Header       = "账户管理",
                ViewResolver = () => _container.Resolve <UserProfileManagementView>()
            });

            normalRegion.Add(
                new NavigationDescriptor()
            {
                ViewName     = "SyncView",
                Header       = "连接手机",
                ViewResolver = () => _container.Resolve <SyncView>()
            });

            _navigationService.RequestNavigate(NormalRegion, "WidgetView");
        }
        public NavigationRegionViewModel(INavigationRegion navigationRegion)
        {
            _navigationRegion = navigationRegion;
            _viewItems = new ObservableCollection<object>();
            PopulateRegion(navigationRegion.NavigationViews);

            _navigationRegion.NavigationViews.CollectionChanged += OnNavigationViewsChanged;
        }
Ejemplo n.º 3
0
        public NavigationRegionViewModel(INavigationRegion navigationRegion)
        {
            _navigationRegion = navigationRegion;
            _viewItems        = new ObservableCollection <object>();
            PopulateRegion(navigationRegion.NavigationViews);

            _navigationRegion.NavigationViews.CollectionChanged += OnNavigationViewsChanged;
        }
Ejemplo n.º 4
0
        private NavigationDescriptor ActivateView(string viewName, INavigationRegion region)
        {
            NavigationDescriptor descriptor = region.ActiveNavigationViews[viewName];

            if (descriptor == null)
            {
                descriptor = region.Activate(viewName);
            }

            return(descriptor);
        }
Ejemplo n.º 5
0
        private INavigationRegion EnsureRegion(string regionName)
        {
            INavigationRegion region = _navigationManager.Regions[regionName];

            if (region == null)
            {
                throw new InvalidOperationException(
                          string.Format("Navigation Region [{0}] does not exist"));
            }

            return(region);
        }
Ejemplo n.º 6
0
        public void AddRegionIfMissing(string regionName, string header)
        {
            INavigationRegion region = _regions[regionName];

            if (region == null)
            {
                region        = ServiceLocator.Current.GetInstance <INavigationRegion>();
                region.Name   = regionName;
                region.Header = header;

                _regions.Add(region);
            }
        }
Ejemplo n.º 7
0
        public void RequestNavigate(string regionName, string viewName, string stateName)
        {
            if (_isInTransition)
            {
                return;
            }
            _isInTransition = true;

            if (string.IsNullOrEmpty(regionName))
            {
                throw new ArgumentNullException("regionName");
            }

            if (string.IsNullOrEmpty(viewName))
            {
                throw new ArgumentNullException("viewName");
            }

            INavigationRegion    region     = EnsureRegion(regionName);
            NavigationDescriptor descriptor = ActivateView(viewName, region);
            ViewState            viewState  = EnsureState(regionName, viewName, stateName, descriptor);

            OnNavigationStart(_previousDescriptor, descriptor, viewState);

            Presenter.TransitionCompleted -= OnTransitionCompleted;

            if (_previousDescriptor != null && _previousDescriptor.ViewName != descriptor.ViewName)
            {
                _targetDescriptor              = descriptor;
                _sourceDescriptor              = _previousDescriptor;
                _targetState                   = viewState;
                Presenter.TransitionCompleted += OnTransitionCompleted;
                Presenter.ApplyTransition(_previousDescriptor.ViewResolver(), descriptor.ViewResolver());
            }
            else
            {
                PostTransition();
            }

            _previousDescriptor = descriptor;
        }
Ejemplo n.º 8
0
        private NavigationDescriptor ActivateView(string viewName, INavigationRegion region)
        {
            NavigationDescriptor descriptor = region.ActiveNavigationViews[viewName];

            if (descriptor == null)
            {
                descriptor = region.Activate(viewName);
            }

            return descriptor;
        }