mobile ads

Friday 11 October 2013

NavigationCommands Memers 2

NavigationCommands.FirstPage

FirstPage property gets the value that represents the First Page Command
KeyGesture   -  N/A
UI Text         -  First Page

This command indicates the intention to go to the first page.
DocumentViewer, FlowDocumentReader, FlowDocumentScrollViewer, and FlowDocumentPageViewer implement support for responding to the FirstPage command
Example

<MenuItem
  Command="NavigationCommands.FirstPage"
  CommandTarget="{Binding ElementName=flowDocumentPageViewer}" />
...

<FlowDocumentPageViewer Name="flowDocumentPageViewer">
  <FlowDocument>
    
    <Paragraph>
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed vulputate,
 lacus non sagittis pharetra, diam dolor dictum tellus, et hendrerit odio risus 
    </Paragraph>
...
  </FlowDocument>
</FlowDocumentPageViewer>

NavigationCommands.NextPage

NextPage property gets the value that represents the Next Page Command
KeyGesture   -  N/A
UI Text         -  Next Page

This command indicates the intention to go to the next page.
DocumentViewer, FlowDocumentReader, FlowDocumentScrollViewer, and FlowDocumentPageViewer implement support for responding to the NextPage command
Example

<MenuItem
  Command="NavigationCommands.NextPage"
  CommandTarget="{Binding ElementName=flowDocumentPageViewer}" />
...

<FlowDocumentPageViewer Name="flowDocumentPageViewer">
  <FlowDocument>
    
    <Paragraph>
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed vulputate,
 lacus non sagittis pharetra, diam dolor dictum tellus, et hendrerit odio risus 
    </Paragraph>
...
  </FlowDocument>
</FlowDocumentPageViewer>

NavigationCommands.LastPage

LastPage property gets the value that represents the Last Page Command
KeyGesture   -  N/A
UI Text         -  Last Page

This command indicates the intention to go to the lastpage.
DocumentViewer, FlowDocumentReader, FlowDocumentScrollViewer, and FlowDocumentPageViewer implement support for responding to the LastPage command
Example

<MenuItem
  Command="NavigationCommands.LastPage"
  CommandTarget="{Binding ElementName=flowDocumentPageViewer}" />
...

<FlowDocumentPageViewer Name="flowDocumentPageViewer">
  <FlowDocument>
    
    <Paragraph>
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed vulputate,
 lacus non sagittis pharetra, diam dolor dictum tellus, et hendrerit odio risus 
    </Paragraph>
...
  </FlowDocument>
</FlowDocumentPageViewer>


NavigationCommands.PreviousPage

PreviousPage property gets the value that represents the PreviousPage Command
KeyGesture   -  N/A
UI Text         -  Previous Page

This command indicates the intention to go to the previouspage.
DocumentViewer, FlowDocumentReader, FlowDocumentScrollViewer, and FlowDocumentPageViewer implement support for responding to the PreviousPage command
Example

<MenuItem
  Command="NavigationCommands.PreviousPage"
  CommandTarget="{Binding ElementName=flowDocumentPageViewer}" />
...

<FlowDocumentPageViewer Name="flowDocumentPageViewer">
  <FlowDocument>
    
    <Paragraph>
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed vulputate,
 lacus non sagittis pharetra, diam dolor dictum tellus, et hendrerit odio risus 
    </Paragraph>
...
  </FlowDocument>
</FlowDocumentPageViewer>

NavigationCommands.NavigateJournal

NavigateJournal property gets the value that represents the NavigateJournal Command
KeyGesture   -  N/A
UI Text         -  Navigate Journal

This command indicates the intention to navigate the journal.
Frame and NavigationWindow implement support for responding to the NavigateJournal command
Example
<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

  <Window.Resources>
    
    <JournalEntryUnifiedViewConverter x:Key="JournalEntryUnifiedViewConverter" />
      
    <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>
      
    <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>
...

<MenuItem
  Header="Navigate Journal"
  ItemTemplate="{StaticResource journalMenuItemTemplate}"
  ItemContainerStyle="{StaticResource journalMenuItemContainerStyle}" >
    
  <MenuItem.ItemsSource>
    <MultiBinding Converter="{StaticResource JournalEntryUnifiedViewConverter}" >
      <Binding ElementName="frame" Path="BackStack"/>
      <Binding ElementName="frame" Path="ForwardStack"/>
    </MultiBinding>
  </MenuItem.ItemsSource>
</MenuItem>
...

<Frame Name="frame" NavigationUIVisibility="Hidden" Source="Page1.xaml" />
...
</Window>

NavigationCommands.Refresh

Refresh property gets the value that represents the Refresh Command

KeyGesture   -  F5
UI Text         -   Refresh

This command indicates the intention to refresh the current page.
Frame and NavigationWindow implement support for responding to the Refresh commandExample

<MenuItem
  Command="NavigationCommands.Refresh"
  CommandTarget="{Binding ElementName=frame}" />
...

<Frame Name="frame" NavigationUIVisibility="Hidden" Source="Page1.xaml" />
 
NavigationCommands.Search


Search property gets the value that represents the Search Command
KeyGesture   -  F3
UI Text         -   Refresh

This command indicates the intention to search.
There is no implementation for responding to the Search command on any given WPF class. As such, you need to provide an appropriate implementation, which is shown in the example.
Example
XAML


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

  <Window.CommandBindings>
    <CommandBinding
      Command="NavigationCommands.Search"
      CanExecute="navigationCommandSearch_CanExecute"
      Executed="navigationCommandSearch_Executed" />
  </Window.CommandBindings>
...

<MenuItem Command="NavigationCommands.Search" />
...
<FlowDocumentPageViewer Name="flowDocumentPageViewer">
  <FlowDocument>
    
    <Paragraph>
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed vulputate,
 lacus non sagittis pharetra, diam dolor dictum tellus, et hendrerit odio risus
 nec erat. Nam sollicitudin imperdiet mi. Sed rutrum. Morbi vel nunc. Donec 
    </Paragraph>
...
  </FlowDocument>
</FlowDocumentPageViewer>
...
</Window>
 
 C#
using System.Windows; // Window 
using System.Windows.Input; // CanExecuteRoutedEventArgs, ExecutedRoutedEventArgs 

namespace SDKSample
{
    public partial class Search : Window
    {
        public Search()
        {
            InitializeComponent();
        }

        void navigationCommandSearch_CanExecute(object sender, CanExecuteRoutedEventArgs e)
        {
            // Can search of there is a document
            e.CanExecute = (this.flowDocumentPageViewer.Document != null);
        }

        void navigationCommandSearch_Executed(object target, ExecutedRoutedEventArgs e)
        {
            // Implement custom Search handling code
        }
    }
}
NavigationCommands.Zoom


Zoom property gets the value that represents the Zoom Command
KeyGesture   - N/A
UI Text         -   Zoom

This command indicates the intention to set the zoom level.
There is no implementation for responding to the Zoom command on any given WPF class. As such, you need to provide an appropriate implementation, which is shown in the example.
Example
<FlowDocumentPageViewer Name="flowDocumentPageViewer" MinZoom="50" MaxZoom="200">

  
  <FlowDocumentPageViewer.ContextMenu>
    <ContextMenu>
      <ContextMenu.CommandBindings>
        <CommandBinding
          Command="NavigationCommands.Zoom"
          CanExecute="navigationCommandZoom_CanExecute"
          Executed="navigationCommandZoom_Executed" />
      </ContextMenu.CommandBindings>
      <MenuItem Header="50%" Command="NavigationCommands.Zoom" CommandParameter="50" />
      <MenuItem Header="100%" Command="NavigationCommands.Zoom" CommandParameter="100" />
      <MenuItem Header="150%" Command="NavigationCommands.Zoom" CommandParameter="150" />
      <MenuItem Header="200%" Command="NavigationCommands.Zoom" CommandParameter="200" />
    </ContextMenu>
  </FlowDocumentPageViewer.ContextMenu>

  <FlowDocument>
    
    <Paragraph>
      Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
 Sed vulputate, lacus non sagittis pharetra, diam dolor dictum tellus, 
et hendrerit odio risus nec erat. Nam sollicitudin imperdiet mi. Sed rutrum.
    </Paragraph>
...
  </FlowDocument>
</FlowDocumentPageViewer>
 
NavigationCommands.Favorites 

Favorites property gets the value that represents the Favorites Command
KeyGesture   -  CTRL+I
UI Text         -  Favorites

This command indicates the intention to manage and navigate to favorites.
Example

<MenuItem Command="NavigationCommands.Favorites">
  <MenuItem.CommandBindings>
    
    <CommandBinding
      Command="NavigationCommands.Favorites"
      CanExecute="navigationCommandFavorites_CanExecute"
      Executed="navigationCommandFavorites_Executed" />
  </MenuItem.CommandBindings>
</MenuItem>
...
<Frame Name="frame" NavigationUIVisibility="Hidden" Source="Page1.xaml" />

2 comments:

Anonymous said...

What is zoom and increasezoom/decreasezoom?

manju said...

This is the difference
For Zoom we need to give CommandParameter i.e., percentage we want to ZOOMIN


Button Command="NavigationCommands.IncreaseZoom"
CommandTarget="{Binding ElementName=richTextBox}"

Button Command="NavigationCommands.DecreaseZoom"
CommandTarget="{Binding ElementName=richTextBox}"


Button Content="Actual Size" CommandParameter="50"
Command="NavigationCommands.Zoom"


Post a Comment