DataPager.xaml
3.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
x:Name="userControl" x:Class="HHECS.Controls.DataPager"
d:DesignHeight="30" d:DesignWidth="600" mc:Ignorable="d" Background="#FFF0F0F0">
<UserControl.Resources>
<Style x:Key="NormalTextBlockStyle" TargetType="{x:Type TextBlock}">
<Setter Property="TextWrapping" Value="NoWrap"/>
<Setter Property="VerticalAlignment" Value="Center"/>
</Style>
<ControlTemplate x:Key="PageButtonTemplate" TargetType="{x:Type Button}">
<TextBlock x:Name="textBlock" VerticalAlignment="Center" Text="{TemplateBinding Content}" HorizontalAlignment="Stretch" Cursor="Hand" Foreground="Blue"/>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" TargetName="textBlock" Value="#FFABA5A5"/>
<Setter Property="Cursor" Value="None"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</UserControl.Resources>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<TextBlock Style="{DynamicResource NormalTextBlockStyle}" Text="共"/>
<TextBlock Text="{Binding TotalCount, ElementName=userControl}" Style="{DynamicResource NormalTextBlockStyle}" Margin="4,0"/>
<TextBlock Style="{DynamicResource NormalTextBlockStyle}" Text="行,每页" />
<TextBlock Text="{Binding PageSize, ElementName=userControl}" Style="{DynamicResource NormalTextBlockStyle}" Margin="4,0"/>
<TextBlock Text="行,第" Style="{DynamicResource NormalTextBlockStyle}"/>
<TextBlock Text="{Binding PageIndex, ElementName=userControl}" Style="{DynamicResource NormalTextBlockStyle}" Margin="4,0,2,0"/>
<TextBlock Text="/" Style="{DynamicResource NormalTextBlockStyle}"/>
<TextBlock Text="{Binding PageCount, ElementName=userControl, Mode=OneWay}" Style="{DynamicResource NormalTextBlockStyle}" Margin="2,0,4,0"/>
<TextBlock Text="页" Style="{DynamicResource NormalTextBlockStyle}"/>
<Button x:Name="btnFirst" Content="首页" Template="{DynamicResource PageButtonTemplate}" VerticalAlignment="Center" Margin="10,0,0,0" Click="btnFirst_Click" IsEnabled="{Binding CanGoFirstOrPrev, ElementName=userControl}" />
<Button x:Name="btnPrev" Content="上一页" Template="{DynamicResource PageButtonTemplate}" VerticalAlignment="Center" Margin="10,0,0,0" Click="btnPrev_Click" IsEnabled="{Binding CanGoFirstOrPrev, ElementName=userControl}" />
<Button x:Name="btnNext" Content="下一页" VerticalAlignment="Center" Template="{DynamicResource PageButtonTemplate}" Margin="10,0,0,0" Click="btnNext_Click" IsEnabled="{Binding CanGoLastOrNext, ElementName=userControl}" />
<Button x:Name="btnLast" VerticalAlignment="Center" Template="{DynamicResource PageButtonTemplate}" Margin="10,0,0,0" Click="btnLast_Click" IsEnabled="{Binding CanGoLastOrNext, ElementName=userControl}" Content="末页" />
<TextBox x:Name="txtPageIndex" Width="40" VerticalAlignment="Center" Margin="10,0,0,0" Text="{Binding PageIndex, ElementName=userControl, Mode=OneWay}"/>
<Button x:Name="btnGoTo" Content="转到" Template="{DynamicResource PageButtonTemplate}" VerticalAlignment="Center" Margin="10,0,0,0" Click="btnGoTo_Click" />
</StackPanel>
</UserControl>