using GalaSoft.MvvmLight.Command;
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;
namespace SlnMesnac.WPF.Templates
{
///
/// Pagination.xaml 的交互逻辑
///
public partial class Pagination : UserControl
{
public Pagination()
{
InitializeComponent();
}
#region 分页数据属性
///
/// 总条数
///
public long Total
{
get { return (long)GetValue(TotalProperty); }
set { SetValue(TotalProperty, value); }
}
public static readonly DependencyProperty TotalProperty =
DependencyProperty.Register("Total", typeof(long), typeof(Pagination), new PropertyMetadata(0l, (s, e) =>
{
((Pagination)s).Total = (long)e.NewValue;
}));
///
/// 总页数
///
public int Page
{
get { return (int)GetValue(PageProperty); }
set { SetValue(PageProperty, value); }
}
public static readonly DependencyProperty PageProperty =
DependencyProperty.Register("Page", typeof(int), typeof(Pagination),
new PropertyMetadata(0, (o, args) =>
{
((Pagination)o).Page = (int)args.NewValue;
}));
///
/// 当前页
///
public int Current
{
get { return (int)GetValue(CurrentProperty); }
set { SetValue(CurrentProperty, value); }
}
public static readonly DependencyProperty CurrentProperty =
DependencyProperty.Register("Current", typeof(int), typeof(Pagination), new PropertyMetadata(1, (o, args) =>
{
((Pagination)o).Page = (int)args.NewValue;
}));
///
/// 分页大小列表
///
public List PageSizes
{
get { return (List)GetValue(PageSizesProperty); }
set { SetValue(PageSizesProperty, value); }
}
public static readonly DependencyProperty PageSizesProperty =
DependencyProperty.Register("PageSizes", typeof(List), typeof(Pagination), new PropertyMetadata(null, (o, args) =>
{
((Pagination)o).PageSizes = (List)args.NewValue;
}));
///
/// 分页大小
///
public int PageSize
{
get { return (int)GetValue(PageSizeProperty); }
set { SetValue(PageSizeProperty, value); }
}
public static readonly DependencyProperty PageSizeProperty =
DependencyProperty.Register("PageSize", typeof(int), typeof(Pagination), new PropertyMetadata(10, (o, args) =>
{
((Pagination)o).PageSize = (int)args.NewValue;
}));
#endregion
#region 分页事件
///
/// 上一页
///
public static readonly DependencyProperty FindPreCommandProperty =
DependencyProperty.Register("PreCommand", typeof(RelayCommand), typeof(Pagination), new PropertyMetadata(null,
(o, args) =>
{
((Pagination)o).PreCommand = (RelayCommand)args.NewValue;
}));
public RelayCommand PreCommand
{
get { return (RelayCommand)GetValue(FindPreCommandProperty); }
set { SetValue(FindPreCommandProperty, value); }
}
public static readonly DependencyProperty NextCommandProperty =
DependencyProperty.Register("NextCommand", typeof(RelayCommand), typeof(Pagination), new PropertyMetadata(null,
(o, args) =>
{
((Pagination)o).NextCommand = (RelayCommand)args.NewValue;
}));
public RelayCommand NextCommand
{
get { return (RelayCommand)GetValue(NextCommandProperty); }
set { SetValue(NextCommandProperty, value); }
}
public static readonly DependencyProperty GoCommandProperty =
DependencyProperty.Register("GoCommand", typeof(RelayCommand), typeof(Pagination), new PropertyMetadata(null,
(o, args) =>
{
((Pagination)o).GoCommand = (RelayCommand)args.NewValue;
}));
public RelayCommand GoCommand
{
get { return (RelayCommand)GetValue(GoCommandProperty); }
set { SetValue(GoCommandProperty, value); }
}
#endregion
}
}