11114I629-0  引入命名空間
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
分頁樣式
<!--測試分頁控制項樣式開始-->
  • <Style x:Key="DataPagerStyle" TargetType="data:DataPager">  
  •              <Setter Property="Background" Value="#FFF2F3F4"/>  
  •              <Setter Property="BorderBrush">  
  •                  <Setter.Value>  
  •                      <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">  
  •                          <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>  
  •                                          <vsm:VisualStateManager.VisualStateGroups>  
  •                                              <vsm:VisualStateGroup x:Name="CommonStates">  
  •                                                  <vsm:VisualState x:Name="Normal"/>  
  •                                                  <vsm:VisualState x:Name="MouseOver">  
  •                                                      <Storyboard>  
  •                                                          <ColorAnimation Duration="0" Storyboard.TargetName="OuterBtnBorder" Storyboard.TargetProperty="(BorderBrush).Color" To="#FFFFFFFF"/>  
  •                                                          <ColorAnimation Duration="0" Storyboard.TargetName="InnerBtnBorder" Storyboard.TargetProperty="(BorderBrush).Color" To="#FFCCD1D6"/>  
  •                                                      </Storyboard>  
  •                                                  </vsm:VisualState>  
  •                                                  <vsm:VisualState x:Name="Pressed">  
  •                                                      <Storyboard>  
  •                                                          <ColorAnimation Duration="0" Storyboard.TargetName="OuterBtnBorder" Storyboard.TargetProperty="(BorderBrush).Color" To="#FFFFFFFF"/>  
  •                                                          <ColorAnimation Duration="0" Storyboard.TargetName="InnerBtnBorder" Storyboard.TargetProperty="(BorderBrush).Color" To="#FFCCD1D6"/>  
  •                                                      </Storyboard>  
  •                                                  </vsm:VisualState>  
  •                                                  <vsm:VisualState x:Name="Disabled">  
  •                                                      <Storyboard>  
  •                                                          <DoubleAnimation Duration="0" Storyboard.TargetName="contentPresenter" Storyboard.TargetProperty="Opacity" To="0.5"/>  
  •                                                      </Storyboard>  
  •                                                  </vsm:VisualState>  
  •                                              </vsm:VisualStateGroup>  
  •                                              <vsm:VisualStateGroup x:Name="CheckStates">  
  •                                                  <vsm:VisualState x:Name="Checked">  
  •                                                      <Storyboard>  
  •                                                          <DoubleAnimation Duration="0" Storyboard.TargetName="CheckedStateOuterBorder" Storyboard.TargetProperty="Opacity" To="1"/>  
  •                                                      </Storyboard>  
  •                                                  </vsm:VisualState>  
  •                                                  <vsm:VisualState x:Name="Unchecked"/>  
  •                                              </vsm:VisualStateGroup>  
  •                                              <vsm:VisualStateGroup x:Name="FocusStates">  
  •                                                  <vsm:VisualState x:Name="Focused">  
  •                                                      <Storyboard>  
  •                                                          <DoubleAnimation Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity" To="1"/>  
  •                                                      </Storyboard>  
  •                                                  </vsm:VisualState>  
  •                                                  <vsm:VisualState x:Name="Unfocused"/>  
  •                                              </vsm:VisualStateGroup>  
  •                                          </vsm:VisualStateManager.VisualStateGroups>  
  •                                          <Border x:Name="CheckedStateOuterBorder" Background="#7FA9A9A9" BorderBrush="#00FFFFFF" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3" Opacity="0"/>  
  •                                          <Border x:Name="OuterBtnBorder" Background="{TemplateBinding Background}" BorderBrush="#00FFFFFF" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">  
  •                                              <Border x:Name="InnerBtnBorder" BorderBrush="#00CCD1D6" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2">  
  •                                                  <ContentPresenter x:Name="contentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" HorizontalAlignment="Center" VerticalAlignment="Center" />  
  •                                              </Border>  
  •                                          </Border>  
  •                                          <Border x:Name="FocusVisualElement" Background="{TemplateBinding Background}" BorderBrush="#FF6DBDD1" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="2" Margin="1" Opacity="0"/>  
  •                                      </Grid>  
  •                                  </ControlTemplate>  
  •                              </Setter.Value>  
  •                          </Setter>  
  •                      </Style>  
  •                  </Setter.Value>  
  •              </Setter>  
  •    
  •              <Setter Property="Template">  
  •                  <Setter.Value>  
  •                      <ControlTemplate TargetType="data:DataPager">  
  •                          <Grid 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>  
  •                                          <vsm:VisualStateManager.VisualStateGroups>  
  •                                              <vsm:VisualStateGroup x:Name="CommonStates">  
  •                                                  <vsm:VisualState x:Name="Normal"/>  
  •                                                  <vsm:VisualState x:Name="MouseOver">  
  •                                                      <Storyboard>  
  •                                                          <ColorAnimation Duration="0" Storyboard.TargetName="OuterBtnBorder" Storyboard.TargetProperty="(BorderBrush).Color" To="#FFFFFFFF"/>  
  •                                                          <ColorAnimation Duration="0" Storyboard.TargetName="InnerBtnBorder" Storyboard.TargetProperty="(BorderBrush).Color" To="#FFCCD1D6"/>  
  •                                                      </Storyboard>  
  •                                                  </vsm:VisualState>  
  •                                                  <vsm:VisualState x:Name="Pressed">  
  •                                                      <Storyboard>  
  •                                                          <ColorAnimation Duration="0" Storyboard.TargetName="OuterBtnBorder" Storyboard.TargetProperty="(BorderBrush).Color" To="#FFFFFFFF"/>  
  •                                                          <ColorAnimation Duration="0" Storyboard.TargetName="InnerBtnBorder" Storyboard.TargetProperty="(BorderBrush).Color" To="#00FFFFFF"/>  
  •                                                      </Storyboard>  
  •                                                  </vsm:VisualState>  
  •                                                  <vsm:VisualState x:Name="Disabled">  
  •                                                      <Storyboard>  
  •                                                          <DoubleAnimation Duration="0" Storyboard.TargetName="path" Storyboard.TargetProperty="Opacity" To="0.5"/>  
  •                                                      </Storyboard>  
  •                                                  </vsm:VisualState>  
  •                                              </vsm:VisualStateGroup>  
  •                                              <vsm:VisualStateGroup x:Name="FocusStates">  
  •                                                  <vsm:VisualState x:Name="Focused">  
  •                                                      <Storyboard>  
  •                                                          <DoubleAnimation Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity" To="1"/>  
  •                                                      </Storyboard>  
  •                                                  </vsm:VisualState>  
  •                                                  <vsm:VisualState x:Name="Unfocused"/>  
  •                                              </vsm:VisualStateGroup>  
  •                                          </vsm:VisualStateManager.VisualStateGroups>  
  •                                          <Border x:Name="OuterBtnBorder" BorderBrush="#00FFFFFF" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" 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" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" 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">  
  •                                                      <vsm:VisualStateManager.VisualStateGroups>  
  •                                                          <vsm:VisualStateGroup x:Name="CommonStates">  
  •                                                              <vsm:VisualState x:Name="Normal"/>  
  •                                                              <vsm:VisualState x:Name="MouseOver">  
  •                                                                  <Storyboard>  
  •                                                                      <ColorAnimation Storyboard.TargetName="MouseOverBorder" Storyboard.TargetProperty="(BorderBrush).Color" To="#FF99C1E2"/>  
  •                                                                  </Storyboard>  
  •                                                              </vsm:VisualState>  
  •                                                              <vsm:VisualState x:Name="Disabled">  
  •                                                                  <Storyboard>  
  •                                                                      <DoubleAnimation Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity" To="1"/>  
  •                                                                  </Storyboard>  
  •                                                              </vsm:VisualState>  
  •                                                              <vsm:VisualState x:Name="ReadOnly">  
  •                                                                  <Storyboard>  
  •                                                                      <DoubleAnimation Storyboard.TargetName="ReadOnlyVisualElement" Storyboard.TargetProperty="Opacity" To="1"/>  
  •                                                                  </Storyboard>  
  •                                                              </vsm:VisualState>  
  •                                                          </vsm:VisualStateGroup>  
  •                                                          <vsm:VisualStateGroup x:Name="FocusStates">  
  •                                                              <vsm:VisualState x:Name="Focused">  
  •                                                                  <Storyboard>  
  •                                                                      <DoubleAnimation Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity" To="1"/>  
  •                                                                  </Storyboard>  
  •                                                              </vsm:VisualState>  
  •                                                              <vsm:VisualState x:Name="Unfocused"/>  
  •                                                          </vsm:VisualStateGroup>  
  •                                                      </vsm:VisualStateManager.VisualStateGroups>  
  •                                                      <Border x:Name="Border" Opacity="1" Background="#66FFFFFF" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="1">  
  •                                                          <Grid>  
  •                                                              <Border x:Name="ReadOnlyVisualElement" Opacity="0" Background="#72F7F7F7"/>  
  •                                                              <Border x:Name="MouseOverBorder" BorderBrush="Transparent" BorderThickness="1">  
  •                                                                  <ScrollViewer BorderThickness="0" IsTabStop="False" Padding="{TemplateBinding Padding}" x:Name="ContentElement" Margin="0,-3,0,0" VerticalAlignment="Top"/>  
  •                                                              </Border>  
  •                                                          </Grid>  
  •                                                      </Border>  
  •                                                      <Border x:Name="DisabledVisualElement" IsHitTestVisible="False" Opacity="0" Background="#A5F7F7F7" BorderBrush="#A5F7F7F7" BorderThickness="{TemplateBinding BorderThickness}"/>  
  •                                                      <Border Margin="1" x:Name="FocusVisualElement" IsHitTestVisible="False" Opacity="0" BorderBrush="#FF6DBDD1" BorderThickness="{TemplateBinding BorderThickness}"/>  
  •                                                  </Grid>  
  •                                              </ControlTemplate>  
  •                                          </Setter.Value>  
  •                                      </Setter>  
  •                                  </Style>  
  •                              </Grid.Resources>  
  •                              <vsm:VisualStateManager.VisualStateGroups>  
  •    
  •                                  <!-- CommonStates -->  
  •                                  <vsm:VisualStateGroup x:Name="CommonStates">  
  •                                      <vsm:VisualState x:Name="Normal"/>  
  •                                      <vsm:VisualState x:Name="Disabled">  
  •                                          <Storyboard>  
  •                                              <DoubleAnimation Storyboard.TargetName="CurrentPagePrefixTextBlock" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0"/>  
  •                                              <DoubleAnimation Storyboard.TargetName="CurrentPageSuffixTextBlock" Storyboard.TargetProperty="Opacity" To="0.5" Duration="0"/>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •                                  </vsm:VisualStateGroup>  
  •    
  •                                  <!-- MoveStates -->  
  •                                  <vsm:VisualStateGroup x:Name="MoveStates">  
  •                                      <vsm:VisualState x:Name="MoveEnabled">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CurrentPageTextBox" Storyboard.TargetProperty="IsEnabled" Duration="0">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="True"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •    
  •                                      <vsm:VisualState x:Name="MoveDisabled">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CurrentPageTextBox" Storyboard.TargetProperty="IsEnabled" Duration="0">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="False"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •                                  </vsm:VisualStateGroup>  
  •    
  •                                  <!-- CanPageFirstStates -->  
  •                                  <vsm:VisualStateGroup x:Name="MoveFirstStates">  
  •                                      <vsm:VisualState x:Name="MoveFirstEnabled">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FirstPageButton" Storyboard.TargetProperty="IsEnabled" Duration="0">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="True"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •    
  •                                      <vsm:VisualState x:Name="MoveFirstDisabled">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FirstPageButton" Storyboard.TargetProperty="IsEnabled" Duration="0">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="False"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •                                  </vsm:VisualStateGroup>  
  •    
  •                                  <!-- CanPagePreviousStates -->  
  •                                  <vsm:VisualStateGroup x:Name="MovePreviousStates">  
  •                                      <vsm:VisualState x:Name="MovePreviousEnabled">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PreviousPageButton" Storyboard.TargetProperty="IsEnabled" Duration="0">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="True"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •    
  •                                      <vsm:VisualState x:Name="MovePreviousDisabled">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PreviousPageButton" Storyboard.TargetProperty="IsEnabled" Duration="0">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="False"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •                                  </vsm:VisualStateGroup>  
  •    
  •                                  <!-- CanPageNextStates -->  
  •                                  <vsm:VisualStateGroup x:Name="MoveNextStates">  
  •                                      <vsm:VisualState x:Name="MoveNextEnabled">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="NextPageButton" Storyboard.TargetProperty="IsEnabled" Duration="0">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="True"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •    
  •                                      <vsm:VisualState x:Name="MoveNextDisabled">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="NextPageButton" Storyboard.TargetProperty="IsEnabled" Duration="0">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="False"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •                                  </vsm:VisualStateGroup>  
  •    
  •                                  <!-- CanPageLastStates -->  
  •                                  <vsm:VisualStateGroup x:Name="MoveLastStates">  
  •                                      <vsm:VisualState x:Name="MoveLastEnabled">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LastPageButton" Storyboard.TargetProperty="IsEnabled" Duration="0">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="True"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •    
  •                                      <vsm:VisualState x:Name="MoveLastDisabled">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LastPageButton" Storyboard.TargetProperty="IsEnabled" Duration="0">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="False"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •                                  </vsm:VisualStateGroup>  
  •    
  •                                  <!-- PagerDisplayModeStates -->  
  •                                  <vsm:VisualStateGroup x:Name="DisplayModeStates">  
  •                                      <vsm:VisualState x:Name="FirstLastNumeric">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="NextPageButton" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PreviousPageButton" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CurrentPageTextBox" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PageDisplay" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •    
  •                                      <vsm:VisualState x:Name="FirstLastPreviousNext">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="NumericButtonPanel" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •    
  •                                      <vsm:VisualState x:Name="FirstLastPreviousNextNumeric">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CurrentPageTextBox" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PageDisplay" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •    
  •                                      <vsm:VisualState x:Name="Numeric">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FirstPageButton" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LastPageButton" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="NextPageButton" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PreviousPageButton" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CurrentPageTextBox" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PageDisplay" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Separator1" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Separator2" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •    
  •                                      <vsm:VisualState x:Name="PreviousNext">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FirstPageButton" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LastPageButton" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="NumericButtonPanel" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •    
  •                                      <vsm:VisualState x:Name="PreviousNextNumeric">  
  •                                          <Storyboard>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FirstPageButton" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="LastPageButton" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="CurrentPageTextBox" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                              <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PageDisplay" Storyboard.TargetProperty="Visibility">  
  •                                                  <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>  
  •                                              </ObjectAnimationUsingKeyFrames>  
  •                                          </Storyboard>  
  •                                      </vsm:VisualState>  
  •                                  </vsm:VisualStateGroup>  
  •    
  •                              </vsm:VisualStateManager.VisualStateGroups>  
  •    
  •                              <!-- DataPager Control Parts -->  
  •                              <Border MinHeight="24" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" VerticalAlignment="Bottom" CornerRadius="2">  
  •                                  <StackPanel Orientation="Horizontal" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="Stretch">  
  •                                      <!--FirstPage Button -->  
  •                                      <Button x:Name="FirstPageButton" Content="首页" Height="20" Width="30" Background="{StaticResource BackgroundColor}" Foreground="{StaticResource ForegroundColor}" BorderBrush="{StaticResource BorderBrushColor}" BorderThickness="1" Padding="1" HorizontalAlignment="Right" VerticalAlignment="Center" HorizontalContentAlignment="Center" Template="{StaticResource ButtonTemplate}">  
  •                                          <!--<Button.Content>  
  •                                              <Grid Height="9" Width="8" >  
  •                                                  <Path Stretch="Fill" Data="M0,1 L1,0 L1,2 Z" Width="5" Height="9" HorizontalAlignment="Right" Fill="{TemplateBinding Foreground}"/>  
  •                                                  <Rectangle Width="2" HorizontalAlignment="Left" Fill="{TemplateBinding Foreground}"/>  
  •                                              </Grid>  
  •                                          </Button.Content>  
  •                                          -->  
  •                                      </Button>  
  •                                       
  •                                        
  •                                      <!--PreviousPage Button-->  
  •                                      <Button Name="PreviousPageButton" Content="上一页" Height="20" Width="40"   Background="{StaticResource BackgroundColor}" Foreground="{StaticResource ForegroundColor}" BorderBrush="{StaticResource BorderBrushColor}" BorderThickness="1" Padding="1" HorizontalAlignment="Right" VerticalAlignment="Center" Template="{StaticResource ButtonTemplate}">  
  •                                          <!--<Button.Content>  
  •                                              <Path Stretch="Fill" Data="M0,1 L1,0 L1,2 Z" Width="5" Height="9" HorizontalAlignment="Center" Fill="{TemplateBinding Foreground}"/>  
  •                                          </Button.Content>-->  
  •                                      </Button>  
  •    
  •                                      <Border x:Name="Separator1" Width="1" Background="#FFCCD1D6" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,0,1,0" Margin="0,3,0,3"/>  
  •                                      <!--Numeric Button Panel-->  
  •                                      <StackPanel x:Name="NumericButtonPanel" Orientation="Horizontal" Margin="1"/>  
  •    
  •                                      <!--Page Display-->  
  •                                      <StackPanel x:Name="PageDisplay" Orientation="Horizontal">  
  •                                          <TextBlock x:Name="CurrentPagePrefixTextBlock" Width="Auto" VerticalAlignment="Center" Margin="4,0,0,0" Foreground="{TemplateBinding Foreground}"/>  
  •                                          <TextBox x:Name="CurrentPageTextBox" TextWrapping="Wrap" Width="40" Height="Auto" VerticalAlignment="Center" Margin="4,2,4,2" Style="{StaticResource PagingTextBoxStyle}" Foreground="{TemplateBinding Foreground}" BorderBrush="{TemplateBinding BorderBrush}"/>  
  •                                          <TextBlock x:Name="CurrentPageSuffixTextBlock" Width="Auto" VerticalAlignment="Center" Margin="0,0,4,0" Foreground="{TemplateBinding Foreground}"/>  
  •                                      </StackPanel>  
  •                                      <Border x:Name="Separator2" Width="1" Background="#FFCCD1D6" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,0,1,0" Margin="0,3,0,3"/>  
  •    
  •                                      <!--NextPage Button-->  
  •                                      <Button x:Name="NextPageButton" Content="下一页" Height="20" Width="40"  Background="{StaticResource BackgroundColor}" Foreground="{StaticResource ForegroundColor}" BorderBrush="{StaticResource BorderBrushColor}" BorderThickness="1" Padding="1"  HorizontalAlignment="Right" VerticalAlignment="Center" Template="{StaticResource ButtonTemplate}">  
  •                                          <!--<Button.Content>  
  •                                              <Path Stretch="Fill" Data="M0,0 L1,1 L0,2 Z" Width="5" Height="9" HorizontalAlignment="Center" Fill="{TemplateBinding Foreground}"/>  
  •                                          </Button.Content>-->  
  •                                      </Button>  
  •    
  •                                      <!--LastPage Button-->  
  •                                      <Button x:Name="LastPageButton" Content="尾页" Height="20" Width="30" Background="{StaticResource BackgroundColor}" Foreground="{StaticResource ForegroundColor}" BorderBrush="{StaticResource BorderBrushColor}" BorderThickness="1" Padding="1" HorizontalAlignment="Right" VerticalAlignment="Center" Template="{StaticResource ButtonTemplate}">  
  •                                          <!--<Button.Content>  
  •                                              <Grid Height="9" Width="8">  
  •                                                  <Path Stretch="Fill" Data="M0,0 L1,1 L0,2 Z" Width="5" Height="9" HorizontalAlignment="Left" Fill="{TemplateBinding Foreground}"/>  
  •                                                  <Rectangle Width="2" HorizontalAlignment="Right" Fill="{TemplateBinding Foreground}"/>  
  •                                              </Grid>  
  •                                          </Button.Content>-->  
  •                                      </Button>  
  •                                  </StackPanel>  
  •                              </Border>  
  •                          </Grid>  
  •                      </ControlTemplate>  
  •                  </Setter.Value>  
  •              </Setter>  
  •          </Style> 
<!--分頁控制項結束-->
調用
<data:DataPager x:Name ="PagerBar" DisplayMode="FirstLastPreviousNextNumeric" VerticalAlignment="Bottom" Style="{StaticResource DataPagerStyle}"
HorizontalAlignment="Center" Source="{Binding}" NumericButtonCount="4" AutoEllipsis="True" Canvas.Top="402" Canvas.Left="116" />
最後給大家給出我自己寫的分頁後臺代碼 後臺每次只取一頁例子

 

public partial class WinFriendPanel : ChildWindow
{
private const int PageSize = 1;//頁大小
private List<int> itemCount = new List<int>();//總記錄
private bool flag = true;//首次載入標誌

 

public WinFriendPanel()
{
InitializeComponent();
InitializeControls();
}

 

/// <summary>
/// 初始化控制項
/// </summary>
private void InitializeControls()
{
this.Name = "playerFriend";
//點擊頁碼的事件,獲取當前頁的資料並綁定到DataGrid
this.PagerBar.PageIndexChanged += (s, e) =>
{
if (!flag)//如果不是首次載入
{
ClientMessagePool.AddSendMessage(ClientCommand.GetPlayerFriend(GameGlobal.CurrentUser.Player.playerId.ToString(), ((DataPager)s).PageIndex + 1, PageSize));
}
flag = false;
};
//預設第一頁數據
ClientMessagePool.AddSendMessage(ClientCommand.GetPlayerFriend(GameGlobal.CurrentUser.Player.playerId.ToString(), 1, PageSize));
}

 

/// <summary>
/// 顯示玩家好友清單
/// </summary>
/// <param name="current">好友清單</param>
public void DisplayPlayerFriends(List<PlayerFriendPage> current)
{
if (current != null)
{
if (flag)//如果首次載入
{
int totalpagers = current[0] != null ? current[0].recordCount : 0;//總記錄數
for (int i = 1; i <= totalpagers; i++)
itemCount.Add(i);
PagedCollectionView pcv = new PagedCollectionView(itemCount);
pcv.PageSize = PageSize;
this.PagerBar.Source = pcv; //這兒會自動觸發this.dataPager1.PageIndexChanged事件
}
PagedCollectionView view = new PagedCollectionView(current);
this.GridListData.ItemsSource = view;
}
}

 

}

 

創作者介紹
創作者 shadow 的頭像
shadow

資訊園

shadow 發表在 痞客邦 留言(0) 人氣()