Sliverlight学习日志(陈立东)

当你停下脚步的时候,想想有很多人还在继续奔跑~!Sliverlight
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

PagingControl

Posted on 2009-07-21 22:01  陈立东  阅读(295)  评论(0)    收藏  举报

<UserControl
 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/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
 x:Class="LiveSearch.PagingControl"
 x:Name="UserControl"
 Width="Auto" Height="Auto" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">

 <UserControl.Resources>
  <DataTemplate x:Key="DataTemplate1">
   <Grid>
    <ToggleButton Content="{Binding Path=Index}" IsChecked="{Binding Path=IsSelected}" Command="{Binding Path=NavigateCommand}" CommandParameter="{Binding Path=Index}" Style="{DynamicResource ButtonPages}" Width="29" Foreground="{DynamicResource PageNumberBrush}"/>
   </Grid>
  </DataTemplate>
  <ControlTemplate x:Key="ItemsControlControlTemplate1" TargetType="{x:Type ItemsControl}">
   <Grid>
    <StackPanel Orientation="Horizontal" IsItemsHost="True"/>
   </Grid>
  </ControlTemplate>
 </UserControl.Resources>

 <Grid VerticalAlignment="Stretch" Width="Auto" Height="Auto">
  <Grid.ColumnDefinitions>
   <ColumnDefinition Width="29"/>
   <ColumnDefinition Width="29"/>
   <ColumnDefinition Width="0.086*"/>
   <ColumnDefinition Width="29"/>
   <ColumnDefinition Width="29"/>
  </Grid.ColumnDefinitions>
  <Grid Margin="-3,0,-3,0" x:Name="controls" VerticalAlignment="Bottom" Height="26" Grid.ColumnSpan="5">

   <Rectangle Opacity="0.1" Stroke="{x:Null}" RadiusX="17.184" RadiusY="17.184" Panel.ZIndex="2" Margin="0,0,0,0" IsHitTestVisible="False">
    <Rectangle.Fill>
     <LinearGradientBrush EndPoint="0.497,0.99" StartPoint="0.499,0.067">
      <GradientStop Color="#FF2A2A2A" Offset="1"/>
      <GradientStop Color="#FF000000" Offset="0"/>
     </LinearGradientBrush>
    </Rectangle.Fill>
   </Rectangle>
   <Rectangle Opacity="0.1" Stroke="{x:Null}" RadiusX="14.859" RadiusY="14.859" Panel.ZIndex="2" Margin="1,1,1,1" IsHitTestVisible="False">
    <Rectangle.Fill>
     <LinearGradientBrush EndPoint="0.497,0.99" StartPoint="0.499,0.067">
      <GradientStop Color="#FF2A2A2A" Offset="1"/>
      <GradientStop Color="#FF000000" Offset="0"/>
     </LinearGradientBrush>
    </Rectangle.Fill>
   </Rectangle>
   <Rectangle Opacity="0.1" Stroke="{x:Null}" RadiusX="14.124" RadiusY="14.124" Margin="2,2,2,2" Panel.ZIndex="2" IsHitTestVisible="False">
    <Rectangle.Fill>
     <LinearGradientBrush EndPoint="0.497,0.99" StartPoint="0.499,0.067">
      <GradientStop Color="#FF2A2A2A" Offset="1"/>
      <GradientStop Color="#FF000000" Offset="0"/>
     </LinearGradientBrush>
    </Rectangle.Fill>
   </Rectangle>

  </Grid>
  <Button Content="First" Style="{DynamicResource PageFirstButtonStyle}" Command="{Binding Path=FirstPageCommand, ElementName=UserControl, Mode=Default}"/>
  <Button Content="Previous" Command="{Binding Path=PreviousPageCommand, ElementName=UserControl, Mode=OneWay}" Style="{DynamicResource PagePreviousButtonStyle}" Grid.Column="1"/>
  <ItemsControl x:Name="Pages" Template="{DynamicResource ItemsControlControlTemplate1}" ItemTemplate="{DynamicResource DataTemplate1}" ItemsSource="{Binding Path=PageNavigateCommands, ElementName=UserControl, Mode=Default}" Grid.Column="2"/>
  <Button Content="Next" Command="{Binding Path=NextPageCommand, ElementName=UserControl, Mode=Default}" RenderTransformOrigin="0.5,0.5" Style="{DynamicResource PageNextButtonStyle}" Grid.Column="3"/>
  <Button Content="Last" Command="{Binding Path=LastPageCommand, ElementName=UserControl, Mode=Default}" RenderTransformOrigin="0.5,0.5" Style="{DynamicResource PageLastButtonStyle}" Grid.Column="4"/>
 </Grid>
</UserControl>