Click here to Skip to main content
15,892,537 members
Articles / Programming Languages / C#

Custom DataPager With PageSize DropDown in Silverlight

Rate me:
Please Sign up or sign in to vote.
4.57/5 (6 votes)
30 Nov 2011CPOL3 min read 28.5K   928   10  
Customizing DataPager with PageSize dropdown in Silverlight.
  • CustomDataPagerWithPageSizeDropDown.zip
    • CustomDataPagerWithPageSizeDropDown.sln
    • CustomDataPagerWithPageSizeDropDown.Web
    • CustomDataPagerWithPageSizeDropDown
      • App.xaml
      • App.xaml.cs
      • Bin
        • Debug
          • AppManifest.xaml
          • ar
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • bg
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • ca
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • cs
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • CustomDataPagerWithPageSizeDropDown.dll
          • CustomDataPagerWithPageSizeDropDown.xap
          • CustomDataPagerWithPageSizeDropDownTestPage.html
          • da
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • de
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Data.resources.dll
          • el
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • es
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Data.resources.dll
          • et
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • eu
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • fi
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • fr
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Data.resources.dll
          • he
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • hr
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • hu
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • id
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • it
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Data.resources.dll
          • ja
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Data.resources.dll
          • ko
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Data.resources.dll
          • lt
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • lv
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • ms
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • nl
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • no
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • pl
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • pt
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • pt-BR
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • ro
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • ru
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Data.resources.dll
          • sk
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • sl
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • sr-Cyrl-CS
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • sr-Latn-CS
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • sv
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • System.ComponentModel.DataAnnotations.dll
          • System.ComponentModel.DataAnnotations.xml
          • System.Windows.Controls.Data.dll
          • System.Windows.Controls.Data.Input.dll
          • System.Windows.Controls.Data.Input.xml
          • System.Windows.Controls.Data.xml
          • System.Windows.Data.dll
          • System.Windows.Data.xml
          • th
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • tr
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • uk
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • vi
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
          • zh-Hans
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Data.resources.dll
          • zh-Hant
            • System.ComponentModel.DataAnnotations.resources.dll
            • System.Windows.Controls.Data.Input.resources.dll
            • System.Windows.Controls.Data.resources.dll
            • System.Windows.Data.resources.dll
      • CustomDataPagerWithPageSizeDropDown.csproj
      • CustomDataPagerWithPageSizeDropDown.csproj.user
      • DummyData.cs
      • MainPage.xaml
      • MainPage.xaml.cs
      • obj
        • Debug
          • TempPE
      • PageConvertor.cs
      • Properties
<UserControl x:Class="CustomDataPagerWithPageSizeDropDown.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:local="clr-namespace:CustomDataPagerWithPageSizeDropDown"
    mc:Ignorable="d"
    d:DesignHeight="431" d:DesignWidth="550"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
    <UserControl.Resources>
        <local:PageComboConvertor x:Key="PageConvertor" />
        <Style x:Key="DataPagerWithPageSize"
               TargetType="sdk:DataPager">
            <Setter Property="Background"
                    Value="#FFF2F3F4" />
            <Setter Property="BorderBrush">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0.5,1"
                                         StartPoint="0.5,0">
                        <GradientStop Color="#FFA3AEB9"
                                      Offset="0" />
                        <GradientStop Color="#FF8399A9"
                                      Offset="0.375" />
                        <GradientStop Color="#FF718597"
                                      Offset="0.375" />
                        <GradientStop Color="#FF617584"
                                      Offset="1" />
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="BorderThickness"
                    Value="1" />
            <Setter Property="HorizontalContentAlignment"
                    Value="Right" />
            <Setter Property="NumericButtonStyle">
                <Setter.Value>
                    <Style TargetType="ToggleButton">
                        <Setter Property="MinHeight"
                                Value="20" />
                        <Setter Property="MinWidth"
                                Value="20" />
                        <Setter Property="HorizontalAlignment"
                                Value="Right" />
                        <Setter Property="VerticalAlignment"
                                Value="Center" />
                        <Setter Property="Background"
                                Value="#00000000" />
                        <Setter Property="BorderThickness"
                                Value="1" />
                        <Setter Property="Padding"
                                Value="1" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ToggleButton">
                                    <Grid>
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualState x:Name="Normal" />
                                                <VisualState x:Name="MouseOver">
                                                    <Storyboard>
                                                        <ColorAnimation Duration="0"
                                                                        To="#FFFFFFFF"
                                                                        Storyboard.TargetProperty="(BorderBrush).Color"
                                                                        Storyboard.TargetName="OuterBtnBorder" />
                                                        <ColorAnimation Duration="0"
                                                                        To="#FFCCD1D6"
                                                                        Storyboard.TargetProperty="(BorderBrush).Color"
                                                                        Storyboard.TargetName="InnerBtnBorder" />
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Pressed">
                                                    <Storyboard>
                                                        <ColorAnimation Duration="0"
                                                                        To="#FFFFFFFF"
                                                                        Storyboard.TargetProperty="(BorderBrush).Color"
                                                                        Storyboard.TargetName="OuterBtnBorder" />
                                                        <ColorAnimation Duration="0"
                                                                        To="#FFCCD1D6"
                                                                        Storyboard.TargetProperty="(BorderBrush).Color"
                                                                        Storyboard.TargetName="InnerBtnBorder" />
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Disabled">
                                                    <Storyboard>
                                                        <DoubleAnimation Duration="0"
                                                                         To="0.5"
                                                                         Storyboard.TargetProperty="Opacity"
                                                                         Storyboard.TargetName="contentPresenter" />
                                                    </Storyboard>
                                                </VisualState>
                                            </VisualStateGroup>
                                            <VisualStateGroup x:Name="CheckStates">
                                                <VisualState x:Name="Checked">
                                                    <Storyboard>
                                                        <DoubleAnimation Duration="0"
                                                                         To="1"
                                                                         Storyboard.TargetProperty="Opacity"
                                                                         Storyboard.TargetName="CheckedStateOuterBorder" />
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Unchecked" />
                                            </VisualStateGroup>
                                            <VisualStateGroup x:Name="FocusStates">
                                                <VisualState x:Name="Focused">
                                                    <Storyboard>
                                                        <DoubleAnimation Duration="0"
                                                                         To="1"
                                                                         Storyboard.TargetProperty="Opacity"
                                                                         Storyboard.TargetName="FocusVisualElement" />
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Unfocused" />
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <Border x:Name="CheckedStateOuterBorder"
                                                BorderBrush="#00FFFFFF"
                                                BorderThickness="{TemplateBinding BorderThickness}"
                                                Background="#7FA9A9A9"
                                                CornerRadius="3"
                                                Opacity="0" />
                                        <Border x:Name="OuterBtnBorder"
                                                BorderBrush="#00FFFFFF"
                                                BorderThickness="{TemplateBinding BorderThickness}"
                                                Background="{TemplateBinding Background}"
                                                CornerRadius="3">
                                            <Border x:Name="InnerBtnBorder"
                                                    BorderBrush="#00CCD1D6"
                                                    BorderThickness="{TemplateBinding BorderThickness}"
                                                    CornerRadius="2">
                                                <ContentPresenter x:Name="contentPresenter"
                                                                  ContentTemplate="{TemplateBinding ContentTemplate}"
                                                                  Content="{TemplateBinding Content}"
                                                                  HorizontalAlignment="Center"
                                                                  VerticalAlignment="Center" />
                                            </Border>
                                        </Border>
                                        <Border x:Name="FocusVisualElement"
                                                BorderBrush="#FF6DBDD1"
                                                BorderThickness="{TemplateBinding BorderThickness}"
                                                Background="{TemplateBinding Background}"
                                                CornerRadius="2"
                                                Margin="1"
                                                Opacity="0" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Setter.Value>
            </Setter>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="sdk:DataPager">
                        <Grid x:Name="Root"
                              Background="Transparent">
                            <Grid.Resources>
                                <SolidColorBrush x:Key="BackgroundColor"
                                                 Color="#00000000" />
                                <SolidColorBrush x:Key="ForegroundColor"
                                                 Color="#FF000000" />
                                <SolidColorBrush x:Key="BorderBrushColor"
                                                 Color="#FFFFFFFF" />
                                <ControlTemplate x:Key="ButtonTemplate"
                                                 TargetType="Button">
                                    <Grid>
                                        <VisualStateManager.VisualStateGroups>
                                            <VisualStateGroup x:Name="CommonStates">
                                                <VisualState x:Name="Normal" />
                                                <VisualState x:Name="MouseOver">
                                                    <Storyboard>
                                                        <ColorAnimation Duration="0"
                                                                        To="#FFFFFFFF"
                                                                        Storyboard.TargetProperty="(BorderBrush).Color"
                                                                        Storyboard.TargetName="OuterBtnBorder" />
                                                        <ColorAnimation Duration="0"
                                                                        To="#FFCCD1D6"
                                                                        Storyboard.TargetProperty="(BorderBrush).Color"
                                                                        Storyboard.TargetName="InnerBtnBorder" />
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Pressed">
                                                    <Storyboard>
                                                        <ColorAnimation Duration="0"
                                                                        To="#FFFFFFFF"
                                                                        Storyboard.TargetProperty="(BorderBrush).Color"
                                                                        Storyboard.TargetName="OuterBtnBorder" />
                                                        <ColorAnimation Duration="0"
                                                                        To="#00FFFFFF"
                                                                        Storyboard.TargetProperty="(BorderBrush).Color"
                                                                        Storyboard.TargetName="InnerBtnBorder" />
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Disabled">
                                                    <Storyboard>
                                                        <DoubleAnimation Duration="0"
                                                                         To="0.5"
                                                                         Storyboard.TargetProperty="Opacity"
                                                                         Storyboard.TargetName="path" />
                                                    </Storyboard>
                                                </VisualState>
                                            </VisualStateGroup>
                                            <VisualStateGroup x:Name="FocusStates">
                                                <VisualState x:Name="Focused">
                                                    <Storyboard>
                                                        <DoubleAnimation Duration="0"
                                                                         To="1"
                                                                         Storyboard.TargetProperty="Opacity"
                                                                         Storyboard.TargetName="FocusVisualElement" />
                                                    </Storyboard>
                                                </VisualState>
                                                <VisualState x:Name="Unfocused" />
                                            </VisualStateGroup>
                                        </VisualStateManager.VisualStateGroups>
                                        <Border x:Name="OuterBtnBorder"
                                                BorderBrush="#00FFFFFF"
                                                BorderThickness="{TemplateBinding BorderThickness}"
                                                Background="{TemplateBinding Background}"
                                                CornerRadius="3">
                                            <Border x:Name="InnerBtnBorder"
                                                    BorderBrush="#00CCD1D6"
                                                    BorderThickness="{TemplateBinding BorderThickness}"
                                                    CornerRadius="2">
                                                <ContentPresenter x:Name="path"
                                                                  Content="{TemplateBinding Content}" />
                                            </Border>
                                        </Border>
                                        <Border x:Name="FocusVisualElement"
                                                BorderBrush="#FF6DBDD1"
                                                BorderThickness="{TemplateBinding BorderThickness}"
                                                Background="{TemplateBinding Background}"
                                                CornerRadius="2"
                                                Margin="1"
                                                Opacity="0" />
                                    </Grid>
                                </ControlTemplate>
                                <Style x:Key="PagingTextBoxStyle"
                                       TargetType="TextBox">
                                    <Setter Property="BorderThickness"
                                            Value="1" />
                                    <Setter Property="Background"
                                            Value="#FFFFFFFF" />
                                    <Setter Property="Foreground"
                                            Value="#FF000000" />
                                    <Setter Property="Padding"
                                            Value="2, 2, 2, -1" />
                                    <Setter Property="Template">
                                        <Setter.Value>
                                            <ControlTemplate TargetType="TextBox">
                                                <Grid x:Name="RootElement">
                                                    <VisualStateManager.VisualStateGroups>
                                                        <VisualStateGroup x:Name="CommonStates">
                                                            <VisualState x:Name="Normal" />
                                                            <VisualState x:Name="MouseOver">
                                                                <Storyboard>
                                                                    <ColorAnimation To="#FF99C1E2"
                                                                                    Storyboard.TargetProperty="(BorderBrush).Color"
                                                                                    Storyboard.TargetName="MouseOverBorder" />
                                                                </Storyboard>
                                                            </VisualState>
                                                            <VisualState x:Name="Disabled">
                                                                <Storyboard>
                                                                    <DoubleAnimation To="1"
                                                                                     Storyboard.TargetProperty="Opacity"
                                                                                     Storyboard.TargetName="DisabledVisualElement" />
                                                                </Storyboard>
                                                            </VisualState>
                                                            <VisualState x:Name="ReadOnly">
                                                                <Storyboard>
                                                                    <DoubleAnimation To="1"
                                                                                     Storyboard.TargetProperty="Opacity"
                                                                                     Storyboard.TargetName="ReadOnlyVisualElement" />
                                                                </Storyboard>
                                                            </VisualState>
                                                        </VisualStateGroup>
                                                        <VisualStateGroup x:Name="FocusStates">
                                                            <VisualState x:Name="Focused">
                                                                <Storyboard>
                                                                    <DoubleAnimation To="1"
                                                                                     Storyboard.TargetProperty="Opacity"
                                                                                     Storyboard.TargetName="FocusVisualElement" />
                                                                </Storyboard>
                                                            </VisualState>
                                                            <VisualState x:Name="Unfocused" />
                                                        </VisualStateGroup>
                                                    </VisualStateManager.VisualStateGroups>
                                                    <Border x:Name="Border"
                                                            BorderBrush="{TemplateBinding BorderBrush}"
                                                            BorderThickness="{TemplateBinding BorderThickness}"
                                                            Background="#66FFFFFF"
                                                            CornerRadius="1"
                                                            Opacity="1">
                                                        <Grid>
                                                            <Border x:Name="ReadOnlyVisualElement"
                                                                    Background="#72F7F7F7"
                                                                    Opacity="0" />
                                                            <Border x:Name="MouseOverBorder"
                                                                    BorderBrush="Transparent"
                                                                    BorderThickness="1">
                                                                <ScrollViewer x:Name="ContentElement"
                                                                              BorderThickness="0"
                                                                              IsTabStop="False"
                                                                              Margin="0,-3,0,0"
                                                                              Padding="{TemplateBinding Padding}"
                                                                              VerticalAlignment="Top" />
                                                            </Border>
                                                        </Grid>
                                                    </Border>
                                                    <Border x:Name="DisabledVisualElement"
                                                            BorderBrush="#A5F7F7F7"
                                                            BorderThickness="{TemplateBinding BorderThickness}"
                                                            Background="#A5F7F7F7"
                                                            IsHitTestVisible="False"
                                                            Opacity="0" />
                                                    <Border x:Name="FocusVisualElement"
                                                            BorderBrush="#FF6DBDD1"
                                                            BorderThickness="{TemplateBinding BorderThickness}"
                                                            IsHitTestVisible="False"
                                                            Margin="1"
                                                            Opacity="0" />
                                                </Grid>
                                            </ControlTemplate>
                                        </Setter.Value>
                                    </Setter>
                                </Style>
                            </Grid.Resources>
                            <VisualStateManager.VisualStateGroups>
                                <VisualStateGroup x:Name="CommonStates">
                                    <VisualState x:Name="Normal" />
                                    <VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Duration="0"
                                                             To="0.5"
                                                             Storyboard.TargetProperty="Opacity"
                                                             Storyboard.TargetName="CurrentPagePrefixTextBlock" />
                                            <DoubleAnimation Duration="0"
                                                             To="0.5"
                                                             Storyboard.TargetProperty="Opacity"
                                                             Storyboard.TargetName="CurrentPageSuffixTextBlock" />
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="MoveStates">
                                    <VisualState x:Name="MoveEnabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0"
                                                                           Storyboard.TargetProperty="IsEnabled"
                                                                           Storyboard.TargetName="CurrentPageTextBox">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="True" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="MoveDisabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0"
                                                                           Storyboard.TargetProperty="IsEnabled"
                                                                           Storyboard.TargetName="CurrentPageTextBox">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="False" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="MoveFirstStates">
                                    <VisualState x:Name="MoveFirstEnabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0"
                                                                           Storyboard.TargetProperty="IsEnabled"
                                                                           Storyboard.TargetName="FirstPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="True" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="MoveFirstDisabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0"
                                                                           Storyboard.TargetProperty="IsEnabled"
                                                                           Storyboard.TargetName="FirstPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="False" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="MovePreviousStates">
                                    <VisualState x:Name="MovePreviousEnabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0"
                                                                           Storyboard.TargetProperty="IsEnabled"
                                                                           Storyboard.TargetName="PreviousPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="True" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="MovePreviousDisabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0"
                                                                           Storyboard.TargetProperty="IsEnabled"
                                                                           Storyboard.TargetName="PreviousPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="False" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="MoveNextStates">
                                    <VisualState x:Name="MoveNextEnabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0"
                                                                           Storyboard.TargetProperty="IsEnabled"
                                                                           Storyboard.TargetName="NextPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="True" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="MoveNextDisabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0"
                                                                           Storyboard.TargetProperty="IsEnabled"
                                                                           Storyboard.TargetName="NextPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="False" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="MoveLastStates">
                                    <VisualState x:Name="MoveLastEnabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0"
                                                                           Storyboard.TargetProperty="IsEnabled"
                                                                           Storyboard.TargetName="LastPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="True" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="MoveLastDisabled">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Duration="0"
                                                                           Storyboard.TargetProperty="IsEnabled"
                                                                           Storyboard.TargetName="LastPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="False" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                                <VisualStateGroup x:Name="DisplayModeStates">
                                    <VisualState x:Name="FirstLastNumeric">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="NextPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="PreviousPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="CurrentPageTextBox">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="PageDisplay">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="FirstLastPreviousNext">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="NumericButtonPanel">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="FirstLastPreviousNextNumeric">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="CurrentPageTextBox">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="PageDisplay">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="Numeric">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="FirstPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="LastPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="NextPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="PreviousPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="CurrentPageTextBox">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="PageDisplay">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="Separator1">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="Separator2">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="PreviousNext">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="FirstPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="LastPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="NumericButtonPanel">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                    <VisualState x:Name="PreviousNextNumeric">
                                        <Storyboard>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="FirstPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="LastPageButton">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="CurrentPageTextBox">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility"
                                                                           Storyboard.TargetName="PageDisplay">
                                                <DiscreteObjectKeyFrame KeyTime="0"
                                                                        Value="Collapsed" />
                                            </ObjectAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </VisualState>
                                </VisualStateGroup>
                            </VisualStateManager.VisualStateGroups>
                            <Border BorderBrush="{TemplateBinding BorderBrush}"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    Background="{TemplateBinding Background}"
                                    CornerRadius="2"
                                    MinHeight="24"
                                    Padding="{TemplateBinding Padding}"
                                    VerticalAlignment="Bottom">
                                <StackPanel HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                            Orientation="Horizontal"
                                            VerticalAlignment="Stretch">
                                    <Button x:Name="FirstPageButton"
                                            BorderBrush="{StaticResource BorderBrushColor}"
                                            BorderThickness="1"
                                            Background="{StaticResource BackgroundColor}"
                                            Foreground="{StaticResource ForegroundColor}"
                                            HorizontalAlignment="Right"
                                            Height="20"
                                            Padding="1"
                                            Template="{StaticResource ButtonTemplate}"
                                            VerticalAlignment="Center"
                                            Width="20">
                                        <Grid Height="9"
                                              Width="8">
                                            <Path Data="M0,1 L1,0 L1,2 Z"
                                                  Fill="{TemplateBinding Foreground}"
                                                  HorizontalAlignment="Right"
                                                  Height="9"
                                                  Stretch="Fill"
                                                  Width="5" />
                                            <Rectangle Fill="{TemplateBinding Foreground}"
                                                       HorizontalAlignment="Left"
                                                       Width="2" />
                                        </Grid>
                                    </Button>
                                    <Button x:Name="PreviousPageButton"
                                            BorderBrush="{StaticResource BorderBrushColor}"
                                            BorderThickness="1"
                                            Background="{StaticResource BackgroundColor}"
                                            Foreground="{StaticResource ForegroundColor}"
                                            HorizontalAlignment="Right"
                                            Height="20"
                                            Padding="1"
                                            Template="{StaticResource ButtonTemplate}"
                                            VerticalAlignment="Center"
                                            Width="20">
                                        <Path Data="M0,1 L1,0 L1,2 Z"
                                              Fill="{TemplateBinding Foreground}"
                                              HorizontalAlignment="Center"
                                              Height="9"
                                              Stretch="Fill"
                                              Width="5" />
                                    </Button>
                                    <Border x:Name="Separator1"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="1,0,1,0"
                                            Background="#FFCCD1D6"
                                            Margin="0,3,0,3"
                                            Width="1" />
                                    <StackPanel x:Name="NumericButtonPanel"
                                                Margin="1"
                                                Orientation="Horizontal" />
                                    <StackPanel x:Name="PageDisplay"
                                                Orientation="Horizontal">
                                        <TextBlock x:Name="CurrentPagePrefixTextBlock"
                                                   Foreground="{TemplateBinding Foreground}"
                                                   Margin="4,0,0,0"
                                                   VerticalAlignment="Center"
                                                   Width="Auto" />
                                        <TextBox x:Name="CurrentPageTextBox"
                                                 BorderBrush="{TemplateBinding BorderBrush}"
                                                 Foreground="{TemplateBinding Foreground}"
                                                 Height="Auto"
                                                 Margin="4,2,4,2"
                                                 Style="{StaticResource PagingTextBoxStyle}"
                                                 TextWrapping="Wrap"
                                                 VerticalAlignment="Center"
                                                 Width="40" />
                                        <TextBlock x:Name="CurrentPageSuffixTextBlock"
                                                   Foreground="{TemplateBinding Foreground}"
                                                   Margin="0,0,4,0"
                                                   VerticalAlignment="Center"
                                                   Width="Auto" />
                                    </StackPanel>
                                    <Border x:Name="Separator2"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="1,0,1,0"
                                            Background="#FFCCD1D6"
                                            Margin="0,3,0,3"
                                            Width="1" />
                                    <Button x:Name="NextPageButton"
                                            BorderBrush="{StaticResource BorderBrushColor}"
                                            BorderThickness="1"
                                            Background="{StaticResource BackgroundColor}"
                                            Foreground="{StaticResource ForegroundColor}"
                                            HorizontalAlignment="Right"
                                            Height="20"
                                            Padding="1"
                                            Template="{StaticResource ButtonTemplate}"
                                            VerticalAlignment="Center"
                                            Width="20">
                                        <Path Data="M0,0 L1,1 L0,2 Z"
                                              Fill="{TemplateBinding Foreground}"
                                              HorizontalAlignment="Center"
                                              Height="9"
                                              Stretch="Fill"
                                              Width="5" />
                                    </Button>
                                    <Button x:Name="LastPageButton"
                                            BorderBrush="{StaticResource BorderBrushColor}"
                                            BorderThickness="1"
                                            Background="{StaticResource BackgroundColor}"
                                            Foreground="{StaticResource ForegroundColor}"
                                            HorizontalAlignment="Right"
                                            Height="20"
                                            Padding="1"
                                            Template="{StaticResource ButtonTemplate}"
                                            VerticalAlignment="Center"
                                            Width="20">
                                        <Grid Height="9"
                                              Width="8">
                                            <Path Data="M0,0 L1,1 L0,2 Z"
                                                  Fill="{TemplateBinding Foreground}"
                                                  HorizontalAlignment="Left"
                                                  Height="9"
                                                  Stretch="Fill"
                                                  Width="5" />
                                            <Rectangle Fill="{TemplateBinding Foreground}"
                                                       HorizontalAlignment="Right"
                                                       Width="2" />
                                        </Grid>
                                    </Button>
                                    <Border x:Name="Separator3"
                                            BorderBrush="{TemplateBinding BorderBrush}"
                                            BorderThickness="1,0,1,0"
                                            Background="#FFCCD1D6"
                                            Margin="0,3,0,3"
                                            Width="1"/>
                                    <TextBlock x:Name="tbPageSize"
                                               Foreground="{TemplateBinding Foreground}"
                                               Margin="4,0,2,0"
                                               Text="Page Size"
                                               VerticalAlignment="Center"
                                               Width="Auto" />
                                    <ComboBox Name="cmbPageSize"
                                              BorderBrush="{TemplateBinding BorderBrush}"
                                              Foreground="{TemplateBinding Foreground}"
                                              Height="Auto"
                                              Margin="4,2,4,2"
                                              VerticalAlignment="Center"
                                              ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent},
                                                            Converter={StaticResource PageConvertor} }"
                                              SelectionChanged="cmbPageSize_SelectionChanged"
                                              Width="60"/>
                                </StackPanel>
                            </Border>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="White">
        <sdk:DataGrid AutoGenerateColumns="True"
                      Height="375"
                      Margin="12,12,12,0"
                      Name="dgGrid"
                      VerticalAlignment="Top" />
        <sdk:DataPager Height="26"
                       Margin="12,393,12,0"
                       Name="dpPager"
                       PageSize="5"
                       VerticalAlignment="Top"
                       Style="{StaticResource DataPagerWithPageSize}"/>
    </Grid>
</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Microsoft
India India
Nothing special .. I like challenges and love my critics.

Microsoft | Bangalore | India

Blog : http://manaspatnaik.com/blog

Twitter@manas_patnaik

Comments and Discussions