public Page1ViewModel(INavigator navigator, INavigationPath navigationPath)
        {
            _navigator = navigator;

            MyUserControl1ViewModel = new MyUserControl1ViewModel(navigator);
            MyUserControl2ViewModel = new MyUserControl2ViewModel(navigationPath);
        }
Exemplo n.º 2
0
        private async Task <INavigationResult> NavigateAsync(
            INavigationPath pageNavInfo,
            NavigationTransitionInfo infoOverride)
        {
            _logger.Log($"{nameof(FrameFacade)}.{nameof(NavigateAsync)}({pageNavInfo})", Category.Info, Priority.Low);

            return(await OrchestrateAsync(
                       parameters : pageNavInfo.Parameters,
                       mode : NavigationMode.New,
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
                       navigate : async() =>
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
            {
                /*
                 * To enable serialization of the frame's state using GetNavigationState,
                 * you must pass only basic types to this method, such as string, char,
                 * numeric, and GUID types. If you pass an object as a parameter, an entry
                 * in the frame's navigation stack holds a reference on the object until the
                 * frame is released or that entry is released upon a new navigation that
                 * diverges from the stack. In general, we discourage passing a non-basic
                 * type as a parameter to Navigate because it can’t be serialized when the
                 * application is suspended, and can consume more memory because a reference
                 * is held by the frame’s navigation stack to allow the application to go forward and back.
                 * https://docs.microsoft.com/en-us/uwp/api/Windows.UI.Xaml.Controls.Frame#Windows_UI_Xaml_Controls_Frame_Navigate_Windows_UI_Xaml_Interop_TypeName_System_Object_
                 */
                var parameter = pageNavInfo.QueryString;
                return _frame.Navigate(
                    sourcePageType: pageNavInfo.View,
                    parameter: parameter,
                    infoOverride: infoOverride);
            }));
        }
 public MyUserControl2ViewModel(INavigationPath navigationPath)
 {
     navigationPath.ListChanged += (s, a) =>
     {
         TaskInfo = "Taskinfo for list " + a;
     };
 }
Exemplo n.º 4
0
        public async Task Navigate(INavigationPath path)
        {
            // major problem here: the lock is not re-entrant, and navigating while inside a navigation will deadlock the thread (waiting for itself to exit)
            // todo change navigation code to cancel old nav requests when a new one is started, instead of locking
            using (await _navigationLock.LockAsync().ConfigureAwait(false)) {

                // we give the navigation request to the current navigation context first, walking down the stack until we find a handler
                for (var frame = _activeFrame; frame != null; frame = frame.Parent) {
                    var resolution = frame.Context.HandleNavigation(path);
                    if (resolution != null) {
                        await ExecuteNavigationAction(resolution).ConfigureAwait(false);
                        OnNavigated(new NavigationEventArgs(CurrentLocation));
                        break;
                    }
                }
            }
        }
Exemplo n.º 5
0
 public bool EvaluateVisibility(INavigationPath currentPath)
 {
     return !(currentPath is HomePath) && !(currentPath is LoginPath);
 }
Exemplo n.º 6
0
 public PathResolution(Func<INavigationPath, Task<INavigationContext>> handler, IEnumerable<INavigationPath> excessPath, INavigationPath matchingPath)
 {
     _handler = handler;
     ExcessPath = excessPath;
     MatchingPath = matchingPath;
 }
Exemplo n.º 7
0
 public virtual PathResolution HandleNavigation(INavigationPath path)
 {
     return Binder.Resolve(path);
 }
Exemplo n.º 8
0
 public Bootstrapper()
 {
     _navigationPath = new NavigationPath();
     _navigator      = new Navigator(_navigationPath);
 }
Exemplo n.º 9
0
 public bool EvaluateVisibility(INavigationPath currentPath)
 {
     return true;
 }
Exemplo n.º 10
0
 public Navigator(INavigationPath navigationPath)
 {
     _navigationPath = navigationPath;
 }
Exemplo n.º 11
0
 public NavigationEventArgs(INavigationPath path)
 {
     Path = path;
 }