• 大小: 2KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-16
  • 语言: C#
  • 标签: WPF  分页控件  

资源简介

项目中需要,参照百度分页实现WPF分页控件,自已写了一个WPF分页控件,分享出来给大家,使用直接将3个文件放在自己工程里即可;

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Secret.Judgement.Data;
using Secret.Judgement.Log;

namespace Secret.Judgement.UI.UC
{
    /// 
    /// ChangePage.xaml 的交互逻辑
    /// 

    public partial class DataPager2 : UserControl
    {
        int _totalPages = 10;

        public int TotalPages
        {
            get { return _totalPages; }
            set { 
                _totalPages = value;

                if (_totalPages < 10)
                {
                    for (int i = _totalPages + 1; i < 11; i++)
                    {
                        Button curBtn = Wrap1.Children[i] as Button;
                        curBtn.Visibility = System.Windows.Visibility.Hidden;
                        curBtn.Width = 0;
                        //curBtn.Margin = ““
                    }
                }
            }
        }
        int _currentPage=1 _prevPage=1;

        public int CurrentPage
        {
            get { return _currentPage; }
            set {
                _currentPage = value;

            }
        }
        //int _beginPage _endPage;
        Button _cancelbtn _selectBtn;

        public myDelegate.changePage  pageIndexChanged;

        public DataPager2()
        {
            InitializeComponent();
            if (_totalPages < 10)
            {
                for(int i = _totalPages;i<11;i++)
                    Wrap1.Children[i].Visibility = System.Windows.Visibility.Hidden;
            }
        }

        private void Button_Click_1(object sender RoutedEventArgs e)
        {
            
            //_selectBtn = e.Source as Button;
            ClickHandler((e.Source as Button).Content.ToString());
        }


        //private LoadPage

        private void ClickHandler(string buttonContent)
        {
            _prevPage = _currentPage;

            if (buttonContent == “◀“)
            {
                if (_currentPage == 2)
                {
                    Wrap1.Children[0].Visibility = System.Windows.Visibility.Hidden;
                }
                Wrap1.Children[11].Visibility = System.Windows.Visibility.Visible;

                _currentPage--;
            }
            else if (buttonContent == “▶“)
            {
                if (_currentPage == (_totalPages-1))
                {
                    Wrap1.Children[11].Visibility = System.Windows.Visibility.Hidden;
                }
                Wrap1.Children[0].Visibility = System.Windows.Visibility.Visible;

                _currentPage++;
            }
            else 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        7965  2017-04-06 21:16  DataPager2.xaml.cs
     文件         341  2017-04-01 00:19  myDelegate.cs
     文件        3059  2017-04-05 18:53  DataPager2.xaml

评论

共有 条评论