设为首页 加入收藏

TOP

WPF简单的分页控件实现(一)
2019-09-17 18:56:58 】 浏览:95
Tags:WPF 简单 控件 实现

XAML代码(使用ItemsControl控件实现):

<UserControl x:Class="SunCreate.Vipf.Client.UI.CityDoor.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" 
             d:DesignHeight="28" d:DesignWidth="450">
    <Grid>
        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
            <!--上一页-->
            <Button x:Name="btnPrePage" Height="28" Background="Transparent" Foreground="#fff" Click="btnPrePage_Click" CommandParameter="{Binding}" VerticalAlignment="Center" Visibility="{Binding NumVisible}">
                <Button.Template>
                    <ControlTemplate>
                        <Border x:Name="border" Background="Transparent" CornerRadius="2">
                            <TextBlock x:Name="txt" Margin="10 0 10 1" Foreground="{TemplateBinding Foreground}" FontSize="{Binding FontSize}" FontWeight="Bold" Text="&lt;&lt;" VerticalAlignment="Center"></TextBlock>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter TargetName="border" Property="Background" Value="#6633ccee"></Setter>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Button.Template>
            </Button>
            <!--页码-->
            <ItemsControl x:Name="itemsControl">
                <ItemsControl.Template>
                    <ControlTemplate>
                        <ItemsPresenter></ItemsPresenter>
                    </ControlTemplate>
                </ItemsControl.Template>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel Orientation="Horizontal"></StackPanel>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Button x:Name="btnNum" Height="28" Background="Transparent" Click="btnNum_Click" CommandParameter="{Binding}" VerticalAlignment="Center" Visibility="{Binding NumVisible}">
                                <Button.Template>
                                    <ControlTemplate>
                                        <Border x:Name="border" Background="Transparent" CornerRadius="2" SnapsToDevicePixels="True">
                                            <TextBlock x:Name="txt" Margin="10 0 10 0" Foreground="{Binding CurrentPageColor}" FontSize="{Binding FontSize}" FontWeight="Bold" Text="{Binding Page}" VerticalAlignment="Center" ></TextBlock>
                                        </Border>
                                        <ControlTemplate.Triggers>
                                            <Trigger Property="IsMouseOver" Value="true">
                                                <
首页 上一页 1 2 3 4 5 下一页 尾页 1/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C#工具:Bootstrap WPF Style,Boot.. 下一篇C#工具:利用HttpClient调用WebApi

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目