/// <summary> /// Registers a Frame object as a NavigationService and returns the instance of the new service. /// </summary> /// <param name="frame">The frame to be used to create the service.</param> /// <param name="frameLevel">The frame level of the new service.</param> /// <returns></returns> public FrameNavigationService RegisterFrameAsNavigationService(Frame frame, FrameLevel frameLevel = FrameLevel.Two) { //Check if the user is trying to register a top-level Navigation Service. if (RootNavigationService != null && frameLevel == FrameLevel.One) { throw new Exception("There can only be one level-one navigation service."); } //If it isn't already in the list, add it. if (navigationServices.Any(x => x.NavigationLevel == frameLevel)) { throw new Exception(); } //Creates the new service. var service = new FrameNavigationService(frame, this, frameLevel); //navigationServices.Add(service); //Returns the new service for the user to use. return(service); }
public void RegisterCustomNavigationService(NavigationServiceBase service, FrameLevel frameLevel = FrameLevel.Two) { //Check if the user is trying to register a top-level Navigation Service. if (RootNavigationService != null && frameLevel == FrameLevel.One) { throw new Exception("There can only be one level-one navigation service."); } //If it isn't already in the list, add it. if (navigationServices.Any(x => x.NavigationLevel == frameLevel)) { throw new Exception(); } if (service == null) { throw new ArgumentNullException(nameof(service)); } service.NavigationLevel = frameLevel; service.NavigationManager = this; navigationServices.Add(service); }
/// <summary> /// Returns the corresponding NavigationService based on the FrameLevel provided. /// </summary> /// <param name="level">The FrameLevel of the service to return.</param> /// <returns></returns> public NavigationServiceBase GetNavigationServiceFromFrameLevel(FrameLevel level = FrameLevel.One) { var service = navigationServices.FirstOrDefault <NavigationServiceBase>(x => x.NavigationLevel == level); return(service); }
/// <summary> /// Removes all NavigationServices with the specified FrameLevel. /// </summary> /// <param name="frameLevel">The FrameLevel used to remove the services.</param> public void UnregisterNavigationServiceByFrameLevel(FrameLevel frameLevel) { navigationServices.RemoveAll(x => x.NavigationLevel == frameLevel); }
internal FrameNavigationService(Frame navFrame, NavigationManager manager, FrameLevel navigationLevel) : this(navFrame, manager) { NavigationLevel = navigationLevel; }