1.xaml
<Border Grid.Row="2">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="首页" Style="{StaticResource PageTextBlock}"
cal:Message.Attach="[Event MouseLeftButtonUp]=[Action HomePage];[Event MouseEnter]=[Action PageGotFocus($view,$eventArgs)];[Event MouseLeave]=[Action PageLostFocus($view,$eventArgs)]"/>
<TextBlock Text="上一页" Style="{StaticResource PageTextBlock}"
cal:Message.Attach="[Event MouseLeftButtonUp]=[Action PreviousPage];[Event MouseEnter]=[Action PageGotFocus($view,$eventArgs)];[Event MouseLeave]=[Action PageLostFocus($view,$eventArgs)]"/>
<TextBlock Text="下一页" Style="{StaticResource PageTextBlock}"
cal:Message.Attach="[Event MouseLeftButtonUp]=[Action NextPage];[Event MouseEnter]=[Action PageGotFocus($view,$eventArgs)];[Event MouseLeave]=[Action PageLostFocus($view,$eventArgs)]"/>
<TextBlock Text="未页" Style="{StaticResource PageTextBlock}"
cal:Message.Attach="[Event MouseLeftButtonUp]=[Action EndPage];[Event MouseEnter]=[Action PageGotFocus($view,$eventArgs)];[Event MouseLeave]=[Action PageLostFocus($view,$eventArgs)]"/>
<TextBox Text="{Binding PageTrueNum}" Name="page" MaxLength="6" IsReadOnly="False" Style="{StaticResource PageTextBox}" />
<TextBlock Text="GO" Style="{StaticResource PageTextBlock}"
cal:Message.Attach="[Event MouseLeftButtonUp]=[Action GoPage(page.Text)];[Event MouseEnter]=[Action PageGotFocus($view,$eventArgs)];[Event MouseLeave]=[Action PageLostFocus($view,$eventArgs)]"/>
<TextBlock Text="共" Style="{StaticResource PageTextBlock}" />
<TextBlock Text="{Binding PageAll}" Style="{StaticResource PageTextBlock}" />
<TextBlock Text="页" Style="{StaticResource PageTextBlock}" />
<TextBlock Text="每页" Style="{StaticResource PageTextBlock}" />
<TextBlock Text="20" Foreground="{Binding PageIdex, Mode=TwoWay, Converter={StaticResource idexcolor20}}" Style="{StaticResource PageTextBlock1}"
cal:Message.Attach="[Event MouseLeftButtonUp]=[Action SetPage($view)]"/>
<TextBlock Text="50" Foreground="{Binding PageIdex, Mode=TwoWay, Converter={StaticResource idexcolor50}}" Style="{StaticResource PageTextBlock1}"
cal:Message.Attach="[Event MouseLeftButtonUp]=[Action SetPage($view)]"/>
<TextBlock Text="100" Foreground="{Binding PageIdex, Mode=TwoWay, Converter={StaticResource idexcolor100}}" Style="{StaticResource PageTextBlock1}"
cal:Message.Attach="[Event MouseLeftButtonUp]=[Action SetPage($view)]"/>
<TextBlock Text="200" Foreground="{Binding PageIdex, Mode=TwoWay, Converter={StaticResource idexcolor200}}" Style="{StaticResource PageTextBlock1}"
cal:Message.Attach="[Event MouseLeftButtonUp]=[Action SetPage($view)]"/>
<TextBlock Text="个" Style="{StaticResource PageTextBlock}" />
</StackPanel>
</Border>
<Style x:Key="PageTextBlock" TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,10,0" />
<Setter Property="FontSize" Value="13" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Foreground" Value="#FF333333" />
</Style>
<Style x:Key="PageTextBlock1" TargetType="TextBlock">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Margin" Value="0,0,10,0" />
<Setter Property="FontSize" Value="13" />
<Setter Property="Cursor" Value="Hand" />
</Style>
<Style x:Key="PageTextBox" TargetType="TextBox">
<Setter Property="Height" Value="25" />
<Setter Property="Width" Value="40" />
<Setter Property="BorderBrush" Value="LightGray" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Bottom" />
</Style>
2.cs
public void NextPage()
{
PageNum++;
if (PageNum == PageAll)
{
PageNum = PageAll - 1;
}
PageList.Clear();
for (int i = PageNum * PageIdex; i < DugList.Count; i++)
{
if (i < PageNum * PageIdex + PageIdex)
{
PageList.Add(DugList[i]);
}
}
}
public void PreviousPage()
{
PageNum--;
if (PageNum == -1)
{
PageNum = 0;
}
PageList.Clear();
for (int i = PageNum * PageIdex; i < DugList.Count; i++)
{
if (i < PageNum * PageIdex + PageIdex)
{
PageList.Add(DugList[i]);
}
}
}
public void HomePage()
{
PageNum = 0;
PageList.Clear();
for (int i = PageNum * PageIdex; i < DugList.Count; i++)
{
if (i < PageNum * PageIdex + PageIdex)
{
PageList.Add(DugList[i]);
}
}
}
public void EndPage()
{
PageNum = PageAll-1;
PageList.Clear();
for (int i = PageNum * PageIdex; i < DugList.Count; i++)
{
if (i < PageNum * PageIdex + PageIdex)
{
PageList.Add(DugList[i]);
}
}
}
public void GoPage(string view)
{
PageTrueNum=int.Parse(view.Trim());
PageNum = PageTrueNum - 1;
if (PageNum == PageAll)
{
PageNum = PageAll - 1;
}
if (PageNum < 0)
{
PageNum = 0;
}
PageList.Clear();
for (int i = PageNum * PageIdex; i < DugList.Count; i++)
{
if (i < PageNum * PageIdex + PageIdex)
{
PageList.Add(DugList[i]);
}
}
}
public void SetPage(object sender)
{
TextBlock tb = (sender as TextBlock);
PageIdex = int.Parse(tb.Text.ToString());
}
public void PageGotFocus(object sender, RoutedEventArgs e)
{
TextBlock text = (TextBlock)sender;
text.TextDecorations = TextDecorations.Underline;
text.Foreground = new SolidColorBrush(Colors.Blue);
}
public void PageLostFocus(object sender, RoutedEventArgs e)
{
TextBlock text = (TextBlock)sender;
text.TextDecorations = null;
text.Foreground = new SolidColorBrush(Colors.Black);
}