mobile ads

Thursday 31 October 2013

Event Handling in ASP.NET


Event is an action or occurrence like mouse click, key press, mouse movements, or any system generated notification. The processes communicate through events. For example, Interrupts are system generated events. When events occur the application should be able to respond to it.
In ASP.Net an event is raised on the client, and handled in the server. For example, a user clicks a button displayed in the browser. A Click event is raised. The browser handles this client-side event by posting it to the server.
The server has a subroutine describing what to do when the event is raised; it is called the event-handler. Therefore, when the event message is transmitted to the server, it checks whether the Click event has an associated event handler, and if it has, the event handler is executed.

All ASP.Net controls are implemented as classes, and they have events which are fired when user performs certain action on them. For example, when a user clicks a button the 'Click' event is generated. For handling these events there are in-built attributes and event handlers. To respond to an event, the event handler is coded

The common control events.
EventAttributeControls
ClickOnClickButton, image button, link button, image map
CommandOnCommandButton, image button, link button
TextChangedOnTextChangedText box
SelectedIndexChangedOnSelectedIndexChangedDrop-down list, list box, radio button list, check box list.
CheckedChangedOnCheckedChangedCheck box, radio button

Some events cause the form to be posted back to the server immediately, these are called the postback events. For example, the click events like, Button.Click. Some events are not posted back to the server immediately, these are called non-postback events.For example, the change events or selection events, such as, TextBox.TextChanged or CheckBox.CheckedChanged, or DropDownList,SelectedIndexChanged.The nonpostback events could be made to post back immediately by setting their AutoPostBack property to true.

The default event for the Page object is the Load event. Similarly every control has a default event. For example, default event for the button control is the Click event.
The default event handler could be created in Visual Studio, just by double clicking the control in design view.

Common Page and Control Events

  • DataBinding . raised when a control bind to a data source
  • Disposed . when the page or the control is released
  • Error . it is an page event, occurs when an unhandled exception is thrown
  • Init . raised when the page or the control is initialized
  • Load . raised when the page or a control is loaded
  • PreRender . raised when the page or the control is to be rendered
  • Unload . raised when the page or control is unloaded from memory
Application and Session Events

The most important application events are:
  • Application_Start . it is raised when the application/website is started
  • Application_End . it is raised when the application/website is stopped
Similarly, the most used Session events are:
  • Session_Start . it is raised when a user first requests a page from the application
  • Session_End . it is raised when the session ends

Wednesday 30 October 2013

ASP.NET Page Validation Controls


  • RequiredFieldValidator—Enables you to require a user to enter a value in a form field.
  • RegularExpressionValidator—Enables you to compare a value against a regular expression.
  • RangeValidator—Enables you to check whether a value falls between a certain minimum and maximum value.
  • CompareValidator—Enables you to compare a value against another value or perform a data type check.
  • CustomValidator—Enables you to perform custom validation.
  • ValidationSummary—Enables you to display a summary of all validation errors in a page.
You can associate the validation controls with any form controls included in ASP.NET Framework. For example, if you want to require a user to enter a value into a TextBox control, you can associate a RequiredFieldValidator control with the TextBox control.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <br />
        Name: <asp:TextBox ID="tbName" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator 
                ID="RequiredFieldValidator1" runat="server"
                ErrorMessage="You must enter your name" 
                ControlToValidate="tbName"  ForeColor="Red"/>
        <br />
        Date of birth: <asp:TextBox ID="tbDOB" runat="server" />
        <asp:RegularExpressionValidator
                ID="RegularExpressionValidator1" runat="server"
                ErrorMessage="Enter a date in the form MM/DD/YYYY"
                ControlToValidate="tbDOB"  ForeColor="Red"
                ValidationExpression="(0[1-9]|1[012])/([1-9]|0[1-9]|[12][0-9]|3[01])/\d{4}"
        />
        <br />
        Amount of candies you eat daily (< than 1000): 
        <asp:TextBox ID="tbCandy" runat="server" />
        <asp:CompareValidator 
            ID="CompareValidator1" runat="server"
            ErrorMessage="Number is not < 1000"
            ControlToValidate="tbCandy"
            Operator="LessThan"  ForeColor="Red"
            ValueToCompare="1000" Type="Integer" />
        <br />
        Number of Doctor visits (1 - 10):
        <asp:TextBox ID="tbDr" runat="server" />
        <asp:RangeValidator 
                ID="RangeValidator1" runat="server"
                ErrorMessage="Enter a value from 1 to 10"
                ControlToValidate="tbDr"  ForeColor="Red"
                MinimumValue="1" MaximumValue="10" />
        <br />
        

        <asp:ValidationSummary runat="server" 
            ID="validationSummary"  ForeColor="Blue"/>

        <br />
        <asp:Button runat="server" Text="Submit" ID="btnSubmit" />
    </div>
    </form>
</body>
</html>


For detailed description in MSDN, Click here

Tuesday 29 October 2013

WPF Introduction


Windows Presentation Foundation (WPF) is a next-generation presentation system for building Windows client applications with visually stunning user experiences. With WPF, you can create a wide range of both standalone and browser-hosted applications.
The core of WPF is a resolution-independent and vector-based rendering engine that is built to take advantage of modern graphics hardware. WPF extends the core with a comprehensive set of application-development features that include Extensible Application Markup Language (XAML), controls, data binding, layout, 2-D and 3-D graphics, animation, styles, templates, documents, media, text, and typography. WPF is included in the Microsoft .NET Framework, so you can build applications that incorporate other elements of the .NET Framework class library.

WPF can be used to develop the following types of applications:

1. Standalone Applications (traditional style Windows applications built as executable assemblies that are installed to and run from the client computer).
2. XAML browser applications (XBAPs) (applications composed of navigation pages that are built as executable assemblies and hosted by Web browsers such as Microsoft Internet Explorer or Mozilla Firefox).
3. Custom Control Libraries (non-executable assemblies containing reusable controls).
4. Class Libraries (non-executable assemblies that contain reusable classes).

WPF Architecture

For every new technology, it is very essential to have a clear idea about its architecture. So before beginning your application, you must grab a few concepts. If you would not like to know WPF in detail, please skip this section. As mentioned earlier, WPF is actually a set of assemblies that build up the entire framework. These assemblies can be categorized as:
  • Managed Layer
  • UnManaged Layer
  • Core API
Managed Layer: Managed layer of WPF is built using a number of assemblies. These assemblies build up the WPF framework, communicate with lower level unmanaged API to render its content. The few assemblies that comprise the WPF framework are:
  1. PresentationFramework.dll: Creates the top level elements like layout panels, controls, windows, styles, etc.
  2. PresentationCore.dll: It holds base types such as UIElement, Visual from which all shapes and controls are Derived in PresentationFramework.dll.
  3. WindowsBase.dll: They hold even more basic elements which are capable of being used outside the WPF environment like Dispatcher object, Dependency Objects. I will discuss each of them later.
Unmanaged Layer (milcore.dll): The unmanaged layer of WPF is called milcore or Media Integration Library Core. It basically translates the WPF higher level objects like layout panels, buttons, animation, etc. into textures that Direct3D expects. It is the main rendering engine of WPF.
WindowsCodecs.dll: This is another low level API which is used for imaging support in WPF applications. WindowsCodecs.dll comprises a number of codecs which encode / decode images into vector graphics that would be rendered into WPF screen.
Direct3D: It is the low level API in which the graphics of WPF is rendered.
User32: It is the primary core API which every program uses. It actually manages memory and process separation.
GDI & Device Drivers: GDI and Device Drivers are specific to the operating system which is also used from the application to access low level APIs.

For more information,Click here

Wednesday 16 October 2013

Difference between Response.Redirect and Server.Transfer

Response.Redirect involves an extra round-trip to the server whereas Server.Transfer conserves server resources by avoiding that extra round-trip. Server.Transfer just changes the focus of the page by directly communicating with server.
         Response.Redirect
  1. Response.Redirect() will send you to a new page, update the address bar and add it to the Browser History. On your browser you can click back.
  2. It redirects the request to some plain HTML pages on our server or to some other web server.
  3. It causes additional roundtrips to the server on each request.
  4. It doesn’t preserve Query String and Form Variables from the original request.
  5. It enables to see the new redirected URL where it is redirected in the browser (and be able to bookmark it if it’s necessary).
  6. Response. Redirect simply sends a message down to the (HTTP 302) browser. 


  1. Server.Transfer
  2. Server.Transfer() does not change the address bar, we cannot hit back.One should use Server.Transfer() when he/she doesn’t want the user to see where he is going. Sometime on a "loading" type page.
  3. It transfers current page request to another .aspx page on the same server.
  4. It preserves server resources and avoids the unnecessary roundtrips to the server.
  5. It preserves Query String and Form Variables (optionally).
  6. It doesn’t show the real URL where it redirects the request in the users Web Browser.
  7. Server.Transfer happens without the browser knowing anything, the browser request a page, but the server returns the content of another.

machine.config and web.config

Machine.Config file specifies the settings that are global to a particular machine.  It is specifically used to store machine and application settings global to all asp.net web sites running in IIS in a computer. A system can have only one machine.config computer. Each .NET Framework such as 1.1, 2.0, 4.0 will have its own machine.config in the %runtime install path%\Config folder.
 This file is located at the following path:
 [Windows Directory]\Microsoft.NET\Framework\[Framework Version]\CONFIG\machine.config
 As web.config file is used to configure one asp .net web application, same way Machine.config file is used to configure the application according to a particular machine. That is, configuration done in machine.config file is affected on any application that runs on a particular machine. Usually, this file is not altered and only web.config is used which configuring applications.
 You can override settings in the Machine.Config file for all the applications in a particular Web site by placing a Web.Config file in the root directory of the Web site as follows:
\InetPub\wwwroot\Web.Config
If you want to override a setting from machine.config for a particular asp.net web site, then you can re-write in web.config of that web site. An asp.net can have any number of web.config files.

Friday 11 October 2013

Difference between Convert.ToString() and .ToString()

We can convert the integer i using i.ToString () or Convert.ToString
The basic difference between them is the Convert function handles NULLS while i.ToString () does not; it will throw a NULL reference exception error. So as good coding practice using convert is always safe.


You can create a class and override the toString method to do anything you want.

The Convert.toString converts the specified value to its equivalent string representation.

Can we define a Private Constructor

Yes, In static classes.
A private constructor is a special instance constructor. It is commonly used in classes that contain static members only. If a class has one or more private constructors and no public constructors, then other classes (except nested classes) are not allowed to create instances of this class. For example:
class NLog
{
    // Private Constructor:
    private NLog() { }

    public static double e = System.Math.E;
}
The declaration of the empty constructor prevents the automatic generation of a default constructor. Note that if you don't use an access modifier with the constructor it will still be private by default. However, the private modifier is usually used explicitly to make it clear that the class cannot be instantiated.
Private constructors are used to prevent the creation of instances of a class when there are no instance fields or methods, such as the math class, or when a method is called to obtain an instance of a class. If all the methods in the class are static, consider making the entire class static.

What is Abstract Class and Interface? Why we use them and at What scenario we use?

AbstractClass: Abtract class cannot be instantiated, it can only be inherited.

When you have a requirement where your base class should provide default implementation of certain methods whereas other methods should be open to being overridden by child classes use abstract classes.

For e.g. again take the example of the Vehicle class above. If we want all classes deriving from Vehicle to implement the Drive() method in a fixed way whereas the other methods can be overridden by child classes. In such a scenario we implement the Vehicle class as an abstract class with an implementation of Drive while leave the other methods / properties as abstract so they could be overridden by child classes.

The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share.

For example a class library may define an abstract class that is used as a parameter to many of its functions and require programmers using that library to provide their own implementation of the class by creating a derived class.


Interface: Interface is like contract between the base class and interface used. If your child classes should all implement a certain group of methods/functionalities but each of the child classes is free to provide its own implementation then use interfaces.

For e.g. if you are implementing a class hierarchy for vehicles implement an interface called Vehicle which has properties like Colour MaxSpeed etc. and methods like Drive(). All child classes like Car Scooter AirPlane SolarCar etc. should derive from this base interface but provide a seperate implementation of the methods and properties exposed by Vehicle.

 If you want your child classes to implement multiple unrelated functionalities in short multiple inheritance use interfaces.

For e.g. if you are implementing a class called SpaceShip that has to have functionalities from a Vehicle as well as that from a UFO then make both Vehicle and UFO as interfaces and then create a class SpaceShip that implements both Vehicle and UFO .


Use an abstract class

  • When creating a class library which will be widely distributed or reused—especially to clients, use an abstract class in preference to an interface; because, it simplifies versioning. This is the practice used by the Microsoft team which developed the Base Class Library. ( COM was designed around interfaces.)

  • Use an abstract class to define a common base class for a family of types.

  • Use an abstract class to provide default behavior.

  • Subclass only a base class in a hierarchy to which the class logically belongs.

 Use an interface

  • When creating a standalone project which can be changed at will, use an interface in preference to an abstract class; because, it offers more design flexibility.

  • Use interfaces to introduce polymorphic behavior without subclassing and to model multiple inheritance—allowing a specific type to support numerous behaviors.

  • Use an interface to design a polymorphic hierarchy for value types.

  • Use an interface when an immutable contract is really intended.

  • A well-designed interface defines a very specific range of functionality. Split up interfaces that contain unrelated functionality.

DataGridView using DataReader

Solution 1
DataReader will read row by row so you make looping to read all records if you want to display all record or any element from record , in other hand dataGridview need to take all data of your records in one package, so the solution is to make centralize store by make class that contains properties and set value for each properties when you read the value of each record and store each object from class that you create in ArrayList so the ArrayList will represent your store.

1.Create a class that contains properties
public class MyDetails
    {
        private int age;

        public int Age
        {
            get { return age; }
            set { age = value; }
        }
        private string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        private int id;

        public int Id
        {
            get { return id; }
            set { id = value; }
           } 
        }
 
2. Create ArrayList to represent data


ArrayList sequence = new ArrayList();
 
3. Retreive data

SqlConnection sqlCon = null;
            try
            {
                sqlCon = new SqlConnection();
                sqlCon.ConnectionString = "Your Connection String";
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = sqlCon;
                cmd.CommandText = "SELECT * FROM StudentInfo";
                sqlCon.Open();
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    MyDetails m = new MyDetails();
                    m.Id = (int)reader[0];
                    m.Name = reader[1].ToString();
                    m.Age = (int)reader[2];
                    sequence.Add(m);
                }
                dataGridView1.DataSource = sequence;
            }
            finally
            {
                sqlCon.Close();
            } 
 

Solution 2

SqlConnection con = new SqlConnection("Connection String");
con.Open();

SqlCommand com = new SqlCommand("SQL Query", con);
SqlDataReader read = com.ExecuteReader();
DataSet ds = new DataSet();
DataTable dt = new DataTable("Table1");
ds.Tables.Add(dt);
ds.Load(read, LoadOption.PreserveChanges, ds.Tables[0]);

gridControl1.DataSource = ds.Tables[0];
 

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" />