public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { string path = String.Empty; SectionNavigator nearestSection = value as SectionNavigator; if (nearestSection == null) { StoryNavigator storyNavigator = value as StoryNavigator; if (storyNavigator != null) { nearestSection = storyNavigator.GetParent() as SectionNavigator; } } // Build a path to the section while (nearestSection != null) { Section section = nearestSection.Content as Section; if (String.IsNullOrEmpty(path)) { // Initialize path = section.Title; } else { path = String.Concat(section.Title, " : ", path); } nearestSection = nearestSection.GetParent() as SectionNavigator; } return(path); }
/// <summary> /// Navigate to a Story's parent section on key input /// </summary> /// <param name="e">EventArgs describing the event</param> private void NavigateToParentSectionOnStory(KeyEventArgs e) { // Check if story is currently displayed StoryNavigator storyNavigator = ServiceProvider.ViewManager.CurrentNavigator as StoryNavigator; if (storyNavigator != null) { if (storyNavigator.GetParent() == null) { // Story has no parent, navigation will not succeed. Navigate to home section instead if (ServiceProvider.ViewManager.NavigationCommands.NavigateToFirstSectionCommand.CanExecute(null)) { ServiceProvider.ViewManager.NavigationCommands.NavigateToFirstSectionCommand.Execute(null); } } else if (ServiceProvider.ViewManager.NavigationCommands.NavigateToParentSectionCommand.CanExecute(null)) { ServiceProvider.ViewManager.NavigationCommands.NavigateToParentSectionCommand.Execute(null); } e.Handled = true; } }