NavigateJournal Property

NavigationCommands.NavigateJournal Property

 

Gets the value that represents the Navigate Journal command.

Namespace:   System.Windows.Input
Assembly:  PresentationCore (in PresentationCore.dll)

static member NavigateJournal : RoutedUICommand with get

Property Value

Type: System.Windows.Input.RoutedUICommand

The routed UI command.

Default Values

Key Gesture

N/A

UI Text

Navigation Journal

This command indicates the intention to navigate the journal.

Frame and NavigationWindow implement support for responding to the NavigateJournal command, although you are not required to use it; in many cases the implementation in response to that command is the responsibility of the application writer.

<object property="NavigationCommands.NavigateJournal"/>

The following example shows how to use NavigateJournal in conjunction with a Frame. The Frame provides an implementation that responds to the NavigateJournal command by navigating to the specified journal entry on either the forward or back stacks of the Frame. The journal entries are provided by the JournalEntryUnifiedViewConverter to the top-level Navigate Journal MenuItem. Each journal entry is bound to a child MenuItem that uses the NavigateJournal command.

<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <Window.Resources>
    <!-- For NavigationCommands.NavigateJournal -->
    <JournalEntryUnifiedViewConverter x:Key="JournalEntryUnifiedViewConverter" />
      <!--Create a DataTemplate to display the navigation history-->
    <DataTemplate x:Key="journalMenuItemTemplate">
      <TextBlock>
        <TextBlock Text="{Binding (JournalEntryUnifiedViewConverter.JournalEntryPosition)}" />
        <TextBlock FontWeight="Bold" FontStyle="Italic">
          <TextBlock Margin="5,0,0,0">(</TextBlock>
          <TextBlock Text="{Binding JournalEntry.Name}"/>
          <TextBlock Margin="5,0,0,0">)</TextBlock>
        </TextBlock>
      </TextBlock>
    </DataTemplate>
      <!--Create a style so that all the MenuItems will use the NavigateJournal command-->
    <Style x:Key="journalMenuItemContainerStyle">
      <Setter Property="MenuItem.Command" Value="NavigationCommands.NavigateJournal" />
      <Setter Property="MenuItem.CommandTarget" Value="{Binding ElementName=frame}" />
      <Setter Property="MenuItem.CommandParameter" Value="{Binding RelativeSource={RelativeSource Self}}" />
    </Style>
  </Window.Resources>
<!-- Create the Navigation menu using the template and style defined in Window.Resources-->
<MenuItem
  Header="Navigate Journal"
  ItemTemplate="{StaticResource journalMenuItemTemplate}"
  ItemContainerStyle="{StaticResource journalMenuItemContainerStyle}" >
    <!--Set the ItemsSource to be the IEnumerable returned from the JournalEntryUnifiedViewConverter-->
  <MenuItem.ItemsSource>
    <MultiBinding Converter="{StaticResource JournalEntryUnifiedViewConverter}" >
      <Binding ElementName="frame" Path="BackStack"/>
      <Binding ElementName="frame" Path="ForwardStack"/>
    </MultiBinding>
  </MenuItem.ItemsSource>
</MenuItem>
<!-- The following Frame is used to process NavigationCommands.NavigateJournal commands -->
<Frame Name="frame" NavigationUIVisibility="Hidden" Source="Page1.xaml" />
</Window>

.NET Framework
Available since 3.0
Return to top
Show:
© 2016 Microsoft