WPF一个简单的分页控件

WPF一个简单的分页控件,如图1。

图1

创建用户控件PageControl.xaml。

<UserControl x:Class="Simple.Calculator.WinForm.Common.PageControl"
             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" 
             mc:Ignorable="d" >
    <UserControl.Resources>
        <!--框样式-->
        <Style TargetType="{x:Type Border}" x:Key="gBox">
            <Setter Property="BorderBrush" Value="CornflowerBlue"/>
            <Setter Property="Background" Value="#dfe6ec"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="CornerRadius" Value="2"/>
            <Setter Property="Padding" Value="5"/>
        </Style>

        <!--公共按钮-->
        <Style TargetType="{x:Type Button}" x:Key="gmButton">
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Padding" Value="5,3,5,3"/>
            <Setter Property="Height" Value="26"/>
            <Setter Property="Cursor" Value="Hand"/>
        </Style>

        <!--文本框-->
        <Style TargetType="{x:Type TextBox}" x:Key="gTextBlock">
            <Setter Property="Height" Value="28"/>
            <Setter Property="Width" Value="160"/>
            <Setter Property="Padding" Value="3"/>
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="BorderBrush" Value="#adb2b5"/>
        </Style>
        
        <!--文本标签-->
        <Style TargetType="{x:Type Label}" x:Key="gLabel">
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="Foreground" Value="#006699"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Right"/>
        </Style>
    </UserControl.Resources>
    <!--分页框-->
    <Border Style="{StaticResource gBox}">
        <StackPanel Orientation="Horizontal">
            <Label Style="{StaticResource gLabel}" Content="转到"/>
            <TextBox Width="50" Style="{StaticResource gTextBlock}" Text="{Binding JumpNum}" />
            <Label Style="{StaticResource gLabel}" Content="页"/>
            <Button Style="{StaticResource gmButton}" Margin="0,0,20,0" Content="GO" Command="{Binding JumpPageCommand}"/>
            <Button Style="{StaticResource gmButton}" Margin="0,0,10,0" Content="上一页" Command="{Binding PrevPageCommand}"/>
            <Button Style="{StaticResource gmButton}"  Content="下一页" Command="{Binding NextPageCommand}"/>

            <Label Style="{StaticResource gLabel}" Content="【当前"/>
            <Label Style="{StaticResource gLabel}" Content="0" Foreground="Red"/>
            <Label Style="{StaticResource gLabel}" Content="页】"/>

            <Label Style="{StaticResource gLabel}" Content="【共"/>
            <Label Style="{StaticResource gLabel}" Content="0" Foreground="Red"/>
            <Label Style="{StaticResource gLabel}" Content="页】"/>

            <Label Style="{StaticResource gLabel}" Content="【共"/>
            <Label Style="{StaticResource gLabel}" Content="0" Foreground="Red"/>
            <Label Style="{StaticResource gLabel}" Content="条记录】"/>
        </StackPanel>
    </Border>
</UserControl>

使用

添加引用:

xmlns:com="clr-namespace:Simple.Calculator.WinForm.Common"

XAML代码:

<!--分页框-->
<com:PageControl />

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

pan_junbiao

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值