一:右键添加新建项,选择新建自定义控件,命名为:KDataPager

   public class KDataPager : Control
{
static KDataPager()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(KDataPager), new FrameworkPropertyMetadata(typeof(KDataPager)));
} #region 变量定义
ComboBox PART_DispalyCount;
Label PART_PrePage;
Label PART_NextPage;
TextBox PART_PageIndex; // 定义13个按钮
#region Label&Border
Label lab1;
Label lab2;
Label lab3;
Label lab4;
Label lab5;
Label lab6;
Label lab7;
Label lab8;
Label lab9;
Label lab10;
Label lab11;
Label lab12;
Label lab13; Border bor1;
Border bor2;
Border bor3;
Border bor4;
Border bor5;
Border bor6;
Border bor7;
Border bor8;
Border bor9;
Border bor10;
Border bor11;
Border bor12;
Border bor13;
#endregion Label&Border_end #endregion 变量定义_end // 下拉框的 ItemsSource
List<string> list = new List<string>();
public List<string> PageSizeItemsSource
{
get { return list; }
set { list = value; }
} #region 依赖属性 /// <summary>
/// 页大小
/// </summary>
public int PageSize
{
get { return (int)GetValue(PageSizeProperty); }
set { SetValue(PageSizeProperty, value); }
} /// <summary>
/// 当前页
/// </summary>
public int PageIndex
{
get { return (int)GetValue(PageIndexProperty); }
set { SetValue(PageIndexProperty, value); }
} /// <summary>
/// 总计录数
/// </summary>
public int Total
{
get { return (int)GetValue(TotalProperty); }
set { SetValue(TotalProperty, value); }
} /// <summary>
/// 是否显示页
/// </summary>
public bool IsShowPaging
{
get { return (bool)GetValue(IsShowPagingProperty); }
set { SetValue(IsShowPagingProperty, value); }
} /// <summary>
/// 总页数
/// </summary>
public int PageCount
{
get { return (int)GetValue(PageCountProperty); }
set { SetValue(PageCountProperty, value); }
} /// <summary>
/// 按钮数
/// </summary>
int ButtonCount = ; /// <summary>
/// 数据源
/// </summary> //使用一个依赖属性作为PageCount的后备存储器。这支持动画、样式、绑定等。
public static readonly DependencyProperty PageCountProperty =
DependencyProperty.Register("PageCount", typeof(int), typeof(KDataPager), new UIPropertyMetadata()); //使用一个可靠的属性作为结束的后备存储器。这支持动画、样式、绑定等。
public static readonly DependencyProperty EndProperty =
DependencyProperty.Register("End", typeof(int), typeof(KDataPager), new UIPropertyMetadata()); //使用一个依赖属性作为开始的后备存储器。这支持动画、样式、绑定等。
public static readonly DependencyProperty StartProperty =
DependencyProperty.Register("Start", typeof(int), typeof(KDataPager), new UIPropertyMetadata()); //使用一个依赖属性作为isshow分页的后备存储器。这支持动画、样式、绑定等。
public static readonly DependencyProperty IsShowPagingProperty =
DependencyProperty.Register("IsShowPaging", typeof(bool), typeof(KDataPager), new UIPropertyMetadata(true)); //使用一个可靠的属性作为总的后备存储器。这支持动画、样式、绑定等
public static readonly DependencyProperty TotalProperty =
DependencyProperty.Register("Total", typeof(int), typeof(KDataPager), new UIPropertyMetadata()); //使用一个依赖属性作为PageIndex的后备存储器。这支持动画、样式、绑定等。
public static readonly DependencyProperty PageIndexProperty =
DependencyProperty.Register("PageIndex", typeof(int), typeof(KDataPager), new UIPropertyMetadata()); //使用一个依赖属性作为PageSize的后备存储器。这支持动画、样式、绑定等。
public static readonly DependencyProperty PageSizeProperty =
DependencyProperty.Register("PageSize", typeof(int), typeof(KDataPager), new UIPropertyMetadata()); #endregion 依赖属性_end //相关命令
/// 下一页
RoutedCommand NextPage_Excuted = new RoutedCommand();
/// 上一页
RoutedCommand PrePageCommand = new RoutedCommand();
/// 跳转页
RoutedCommand GoToCommand = new RoutedCommand(); /// <summary>
/// 重写方法
/// </summary>
public override void OnApplyTemplate()
{
base.OnApplyTemplate(); #region 获取模板中的控件
PART_DispalyCount = GetTemplateChild("PART_DispalyCount") as ComboBox;
PART_PrePage = GetTemplateChild("PART_PrePage") as Label;
PART_NextPage = GetTemplateChild("PART_NextPage") as Label;
PART_PageIndex = GetTemplateChild("PART_PageIndex") as TextBox; #region label & border控件
//label
lab1 = GetTemplateChild("lab1") as Label;
lab2 = GetTemplateChild("lab2") as Label;
lab3 = GetTemplateChild("lab3") as Label;
lab4 = GetTemplateChild("lab4") as Label;
lab5 = GetTemplateChild("lab5") as Label;
lab6 = GetTemplateChild("lab6") as Label;
lab7 = GetTemplateChild("lab7") as Label;
lab8 = GetTemplateChild("lab8") as Label;
lab9 = GetTemplateChild("lab9") as Label;
lab10 = GetTemplateChild("lab10") as Label;
lab11 = GetTemplateChild("lab11") as Label;
lab12 = GetTemplateChild("lab12") as Label;
lab13 = GetTemplateChild("lab13") as Label;
//border
bor1 = GetTemplateChild("bor1") as Border;
bor2 = GetTemplateChild("bor2") as Border;
bor3 = GetTemplateChild("bor3") as Border;
bor4 = GetTemplateChild("bor4") as Border;
bor5 = GetTemplateChild("bor5") as Border;
bor6 = GetTemplateChild("bor6") as Border;
bor7 = GetTemplateChild("bor7") as Border;
bor8 = GetTemplateChild("bor8") as Border;
bor9 = GetTemplateChild("bor9") as Border;
bor10 = GetTemplateChild("bor10") as Border;
bor11 = GetTemplateChild("bor11") as Border;
bor12 = GetTemplateChild("bor12") as Border;
bor13 = GetTemplateChild("bor13") as Border;
#endregion label & border控件_end #endregion 获取模板中的控件_end //添加控件事件
PART_NextPage.MouseLeftButtonUp += PART_NextPage_MouseLeftButtonUp; ;
PART_PrePage.MouseLeftButtonUp += PART_PrePage_MouseLeftButtonUp; ;
PART_PageIndex.KeyUp += GOTO;
PART_DispalyCount.SelectionChanged += PART_DispalyCount_SelectionChanged;
//label 绑定同个事件
lab1.MouseLeftButtonUp += Lab1_MouseLeftButtonUp;
lab2.MouseLeftButtonUp += Lab1_MouseLeftButtonUp;
lab3.MouseLeftButtonUp += Lab1_MouseLeftButtonUp;
lab4.MouseLeftButtonUp += Lab1_MouseLeftButtonUp;
lab5.MouseLeftButtonUp += Lab1_MouseLeftButtonUp;
lab6.MouseLeftButtonUp += Lab1_MouseLeftButtonUp;
lab7.MouseLeftButtonUp += Lab1_MouseLeftButtonUp;
lab8.MouseLeftButtonUp += Lab1_MouseLeftButtonUp;
lab9.MouseLeftButtonUp += Lab1_MouseLeftButtonUp;
lab10.MouseLeftButtonUp += Lab1_MouseLeftButtonUp;
lab11.MouseLeftButtonUp += Lab1_MouseLeftButtonUp;
lab12.MouseLeftButtonUp += Lab1_MouseLeftButtonUp;
lab13.MouseLeftButtonUp += Lab1_MouseLeftButtonUp;
//加载
ReCalcLayout();
} #region 事件 /// <summary>
/// 点击
/// </summary>
private void Lab1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
Label dg = sender as Label;
//获取点击按钮的值
var cont = dg.Content.ToString();
if (cont != "...")
{
//清除其他按钮样式,设置点击按钮的样式
BtnClick(cont);
}
} /// <summary>
/// 上一页
/// </summary>
private void PART_PrePage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (PageIndex > )
{
if (PageCount - PageIndex < (ButtonCount - ))
{
BorderPressedStyle(ButtonCount - (PageCount - PageIndex) - );
PageIndex--;
}
else
{
PageIndex--;
BeforeSeven(PageIndex);
}
if (PageCount - PageIndex == ButtonCount)
lab8.Content = "...";
}
} /// <summary>
/// 下一页
/// </summary>
private void PART_NextPage_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
if (PageCount - (ButtonCount - ) > PageIndex)
{
PageIndex++;
if (PageCount - (ButtonCount - ) == PageIndex)
lab8.Content = PageCount - ;
BeforeSeven(PageIndex);
}
else
{
if (PageIndex < PageCount)
{
PageIndex++;
// ButtonCount - (PageCount - PageIndex); --
BorderPressedStyle(ButtonCount - (PageCount - PageIndex));
}
}
} /// <summary>
/// 跳转
/// </summary>
private void GOTO(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
int page = ;
try
{
page = (int)Convert.ToDouble(PART_PageIndex.Text);
}
catch
{
MessageBox.Show("请输入正确的数值!");
}
if (page > PageCount)
{
PageIndex = PageCount;
}
else if (page < )
{
PageIndex = ;
}
else
{
PageIndex = page;
if (PageCount - PageIndex >= ButtonCount)
lab8.Content = "...";
}
BtnClick(PageIndex.ToString());
}
} /// <summary>
/// 改变选中值发生的事件
/// </summary>
void PART_DispalyCount_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ReCalcLayout();
} #endregion 事件_end #region 方法 /// <summary>
/// 点击按钮
/// </summary>
/// <param name="cont">点击按钮的数值</param>
public void BtnClick(string count)
{
var ct = int.Parse(count);
PageIndex = ct;
if (PageCount - PageIndex >= ButtonCount)
{
BorderPressedStyle();
BeforeSeven(ct);
}
else if (PageCount - PageIndex == (ButtonCount - ))
{
BorderPressedStyle();
if (PageCount > ButtonCount)
lab8.Content = PageCount - ;
BeforeSeven(PageIndex);
}
else
{
BorderPressedStyle(ButtonCount - (PageCount - ct));
if (PageCount > ButtonCount)
lab8.Content = PageCount - ;
BeforeSeven(PageCount - (ButtonCount - ));
}
} /// <summary>
/// 后6个label控件赋值
/// </summary>
public void AfterSix(int count)
{
Hidden(count + );
if (count <= )
Assign(count);
else /* if (count > ButtonCount) */
{
lab13.Content = count;
lab12.Content = count - ;
lab11.Content = count - ;
lab10.Content = count - ;
lab9.Content = count - ;
if (count > )
{
lab8.Content = "...";
}
else
{
lab9.Content = count - ;
}
}
} /// <summary>
/// 前7个label控件赋值
/// </summary>
public void BeforeSeven(int count)
{
lab1.Content = count;
lab2.Content = count + ;
lab3.Content = count + ;
lab4.Content = count + ;
lab5.Content = count + ;
lab6.Content = count + ;
lab7.Content = count + ;
} /// <summary>
/// 小于ButtonCount页的直接显示
/// </summary>
/// <param name="Q"></param>
public void Assign(int LabelStart)
{
switch (LabelStart)
{
case :
goto q1;
case :
goto q2;
case :
goto q3;
case :
goto q4;
case :
goto q5;
case :
goto q6;
case :
goto q7;
case :
goto q8;
case :
goto q9;
case :
goto q10;
case :
goto q11;
case :
goto q12;
case :
goto q13;
}
return;
q13: lab13.Content = ;
q12: lab12.Content = ;
q11: lab11.Content = ;
q10: lab10.Content = ;
q9: lab9.Content = ;
q8: lab8.Content = ;
q7: lab7.Content = ;
q6: lab6.Content = ;
q5: lab5.Content = ;
q4: lab4.Content = ;
q3: lab3.Content = ;
q2: lab2.Content = ;
q1: lab1.Content = ;
} /// <summary>
/// 小于ButtonCount的隐藏部分按钮
/// </summary>
/// <param name="P"></param>
public void Hidden(int BorderStart)
{
//全部显示
bor1.Visibility = Visibility.Visible;
bor2.Visibility = Visibility.Visible;
bor3.Visibility = Visibility.Visible;
bor4.Visibility = Visibility.Visible;
bor5.Visibility = Visibility.Visible;
bor6.Visibility = Visibility.Visible;
bor7.Visibility = Visibility.Visible;
bor8.Visibility = Visibility.Visible;
bor9.Visibility = Visibility.Visible;
bor10.Visibility = Visibility.Visible;
bor11.Visibility = Visibility.Visible;
bor12.Visibility = Visibility.Visible;
bor13.Visibility = Visibility.Visible;
switch (BorderStart)
{
case :
goto p1;
case :
goto p2;
case :
goto p3;
case :
goto p4;
case :
goto p5;
case :
goto p6;
case :
goto p7;
case :
goto p8;
case :
goto p9;
case :
goto p10;
case :
goto p11;
case :
goto p12;
case :
goto p13;
}
return;
// 之后部分隐藏
p1: bor1.Visibility = Visibility.Hidden;
p2: bor2.Visibility = Visibility.Hidden;
p3: bor3.Visibility = Visibility.Hidden;
p4: bor4.Visibility = Visibility.Hidden;
p5: bor5.Visibility = Visibility.Hidden;
p6: bor6.Visibility = Visibility.Hidden;
p7: bor7.Visibility = Visibility.Hidden;
p8: bor8.Visibility = Visibility.Hidden;
p9: bor9.Visibility = Visibility.Hidden;
p10: bor10.Visibility = Visibility.Hidden;
p11: bor11.Visibility = Visibility.Hidden;
p12: bor12.Visibility = Visibility.Hidden;
p13: bor13.Visibility = Visibility.Hidden;
} /// <summary>
/// 普通的样式
/// </summary>
public void UnPressedStyle(Border b, Label l)
{
b.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFFFF"));
b.BorderThickness = new Thickness();
b.BorderBrush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#D9D9D9"));
l.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#000000"));
} /// <summary>
/// 按下的样式
/// </summary>
public void PressedStyle(Border b, Label l)
{
b.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#E9F5FF"));
b.BorderThickness = new Thickness();
l.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#3A5F8A"));
} /// <summary>
/// 哪个border是按下的样式
/// </summary>
/// <param name="O">控件值</param>
public void BorderPressedStyle(int WhichOneBorder)
{
//全部设置为普通样式
UnPressedStyle(bor1, lab1);
UnPressedStyle(bor2, lab2);
UnPressedStyle(bor3, lab3);
UnPressedStyle(bor4, lab4);
UnPressedStyle(bor5, lab5);
UnPressedStyle(bor6, lab6);
UnPressedStyle(bor7, lab7);
UnPressedStyle(bor8, lab8);
UnPressedStyle(bor9, lab9);
UnPressedStyle(bor10, lab10);
UnPressedStyle(bor11, lab11);
UnPressedStyle(bor12, lab12);
UnPressedStyle(bor13, lab13);
//按下的设置为按下样式
switch (WhichOneBorder)
{
case :
PressedStyle(bor1, lab1); break;
case :
PressedStyle(bor2, lab2); break;
case :
PressedStyle(bor3, lab3); break;
case :
PressedStyle(bor4, lab4); break;
case :
PressedStyle(bor5, lab5); break;
case :
PressedStyle(bor6, lab6); break;
case :
PressedStyle(bor7, lab7); break;
case :
PressedStyle(bor8, lab8); break;
case :
PressedStyle(bor9, lab9); break;
case :
PressedStyle(bor10, lab10); break;
case :
PressedStyle(bor11, lab11); break;
case :
PressedStyle(bor12, lab12); break;
case :
PressedStyle(bor13, lab13); break;
}
} /// <summary>
/// 获取ComboBox显示的页记录数
/// </summary>
public void GetPageSize(ComboBox cbbx)
{
string str = cbbx.SelectedItem.ToString();
str = Regex.Match(str, ".+\\d").ToString();
PageSize = int.Parse(str.Substring(str.IndexOf(":") + , str.Length));
} /// <summary>
/// 刷新页数
/// </summary>
private void ReCalcLayout()
{
GetPageSize(PART_DispalyCount);
int pc = Total / PageSize;
if (Total % PageSize == )
{
PageCount = pc;
}
else
{
PageCount = pc + ;
}
//刷新后从第一页开始
PageIndex = ;
BorderPressedStyle(PageIndex);
BeforeSeven();
AfterSix(PageCount);
ButtonCount = PageCount > ? : PageCount;
}
#endregion 方法_end }

二:删除Themes/Generic.xaml里面新添加的模板:

//没错了,就是它,删除掉吧
<Style TargetType="{x:Type local:KDataPager}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:KDataPager}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

三:在Themes中添加资源字典文件,命名为DataPager.xaml,并换成如下代码:

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:loc="clr-namespace:Kingo.ProvinceLandSurvey.BaseControl.DataPager"
xmlns:my="clr-namespace:Kingo.ProvinceLandSurvey.BaseControl"
>
<Style x:Key="borL" TargetType="Border">
<Setter Property="BorderThickness" Value="1"></Setter>
<Setter Property="BorderBrush" Value="#D9D9D9"></Setter>
<Setter Property="CornerRadius" Value="2"></Setter>
<Setter Property="Width" Value="28"></Setter>
<Setter Property="Height" Value="28"></Setter>
<Setter Property="Margin" Value="4"></Setter>
<Setter Property="Cursor" Value="Hand"></Setter>
</Style>
<Style x:Key="labL" TargetType="Label">
<Setter Property="Padding" Value="2,0,2,0"></Setter>
<Setter Property="VerticalContentAlignment" Value="Center"></Setter>
<Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
</Style>
<Style x:Key="LabDowe" TargetType="Label">
<Setter Property="FontSize" Value="12"></Setter>
<Setter Property="Foreground" Value="#999999"></Setter>
<Setter Property="VerticalContentAlignment" Value="Center"></Setter>
<Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#F2F2F2"></Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Background" Value="#FFF"></Setter>
</Trigger>
</Style.Triggers>
</Style>
<Style x:Key="{x:Type loc:KDataPager}" TargetType="{x:Type loc:KDataPager}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type loc:KDataPager}">
<Border Background="#FFF">
<StackPanel Orientation="Horizontal">
<!--#region 上一页-->
<Border BorderThickness="1" BorderBrush="#D9D9D9" CornerRadius="2" Width="28" Height="28" Margin="2">
<Label x:Name="PART_PrePage" Content="&lt;" Style="{StaticResource labL}"></Label>
</Border> <!--#region 13页-->
<Border>
<StackPanel Orientation="Horizontal">
<Border x:Name="bor1" BorderThickness="0" Background="#E9F5FF" Style="{StaticResource borL}">
<Label x:Name="lab1" Content="1" Foreground="#3A5F8A" Style="{StaticResource labL}"></Label>
</Border>
<Border x:Name="bor2" Style="{StaticResource borL}">
<Label x:Name="lab2" Content="2" Style="{StaticResource labL}"></Label>
</Border>
<Border x:Name="bor3" Style="{StaticResource borL}">
<Label x:Name="lab3" Content="3" Style="{StaticResource labL}"></Label>
</Border>
<Border x:Name="bor4" Style="{StaticResource borL}">
<Label x:Name="lab4" Content="4" Style="{StaticResource labL}"></Label>
</Border>
<Border x:Name="bor5" Style="{StaticResource borL}">
<Label x:Name="lab5" Content="5" Style="{StaticResource labL}"></Label>
</Border>
<Border x:Name="bor6" Style="{StaticResource borL}">
<Label x:Name="lab6" Content="6" Style="{StaticResource labL}"></Label>
</Border>
<Border x:Name="bor7" Style="{StaticResource borL}">
<Label x:Name="lab7" Content="7" Style="{StaticResource labL}"></Label>
</Border>
<Border x:Name="bor8" Style="{StaticResource borL}">
<Label x:Name="lab8" Content="8" Style="{StaticResource labL}"></Label>
</Border>
<Border x:Name="bor9" Style="{StaticResource borL}">
<Label x:Name="lab9" Content="9" Style="{StaticResource labL}"></Label>
</Border>
<Border x:Name="bor10" Style="{StaticResource borL}">
<Label x:Name="lab10" Content="10" Style="{StaticResource labL}"></Label>
</Border>
<Border x:Name="bor11" Style="{StaticResource borL}">
<Label x:Name="lab11" Content="11" Style="{StaticResource labL}"></Label>
</Border>
<Border x:Name="bor12" Style="{StaticResource borL}">
<Label x:Name="lab12" Content="12" Style="{StaticResource labL}"></Label>
</Border>
<Border x:Name="bor13" Style="{StaticResource borL}">
<Label x:Name="lab13" Content="13" Style="{StaticResource labL}"></Label>
</Border>
</StackPanel>
</Border>
<!--#endregion 13页_end--> <!--#region 下一页-->
<Border BorderThickness="1" BorderBrush="#D9D9D9" CornerRadius="2" Width="28" Height="28" Margin="2">
<Label x:Name="PART_NextPage" Content="&gt;" Style="{StaticResource labL}"></Label>
</Border> <!--#region 条数-->
<Border Margin="30,-40,0,0">
<StackPanel Orientation="Horizontal">
<Border BorderBrush="#D9D9D9" CornerRadius="2,0,0,2" Height="28" Margin="0,40,0,0">
<Border.BorderThickness>
<Thickness Top="1" Bottom="1" Left="1"></Thickness>
</Border.BorderThickness>
<my:KComboBox x:Name="PART_DispalyCount" Width="100" Height="30" Foreground="#666" FontFamily="'kern' 1" FontSize="14" Padding="5,0,0,0" SelectedIndex="0"
ItemsSource="{Binding PageSizeItemsSource,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}">
</my:KComboBox>
</Border>
</StackPanel>
</Border> <!--#region 跳转-->
<Border Margin="8,0,0,0">
<StackPanel Orientation="Horizontal">
<Label Content="跳至" Style="{StaticResource labL}" Margin="5"></Label>
<Border Width="47" Height="28" CornerRadius="2" BorderThickness="1" BorderBrush="#D9D9D9">
<TextBox x:Name="PART_PageIndex" Height="22" VerticalContentAlignment="Center" HorizontalContentAlignment="Left" BorderThickness="0"></TextBox>
</Border>
<Label Content="页" Style="{StaticResource labL}" Margin="5"></Label>
</StackPanel>
</Border> </StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

四:在Themes/Generic.xaml里面加上上一步添加的资源字典文件

    <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/BaseControl;component/Themes/DataPager.xaml" />
</ResourceDictionary.MergedDictionaries>

五:用法:

               //头文件添加引用:xmlns:sys="clr-namespace:System;assembly=mscorlib"
         <my:KDataPager Total="300">
<my:KDataPager.PageSizeItemsSource>
<sys:String>10条/页</sys:String>
<sys:String>20条/页</sys:String>
<sys:String>30条/页</sys:String>
<sys:String>50条/页</sys:String>
<sys:String>100条/页</sys:String>
<sys:String>200条/页</sys:String>
</my:KDataPager.PageSizeItemsSource>
</my:KDataPager>

六:说明:

资源字典中嵌套了一个自定义控件,继承的是ComboBox,名称是KComboBox。如下:

<my:KComboBox x:Name="PART_DispalyCount" Width="100" Height="30" Foreground="#666" FontFamily="'kern' 1" FontSize="14" Padding="5,0,0,0" SelectedIndex="0"
ItemsSource="{Binding PageSizeItemsSource,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}">
</my:KComboBox>

换成下面的代码,照样可以

 <ComboBox x:Name="PART_DispalyCount" Width="100" Height="30" Foreground="#666" FontFamily="'kern' 1" FontSize="14" Padding="5,0,0,0" SelectedIndex="0"
ItemsSource="{Binding PageSizeItemsSource,RelativeSource={RelativeSource TemplatedParent},Mode=TwoWay}">
</ComboBox>

WPF 自定义分页控件一的更多相关文章

  1. WPF自定义分页控件,样式自定义,简单易用

    WPF自定义分页控件 做了许久伸手党,终于有机会贡献一波,搜索一下WPF分页控件,还是多,但是不太通用,主要就是样式问题,这个WPF很好解决,还有一个就是分页控件嘛,只关心几个数字的变动就行了,把页码 ...

  2. WPF 自定义分页控件二

    一:添加自定义分页控件,命名为KDataPagerTwo: public class KDataPagerTwo : Control, INotifyPropertyChanged { static ...

  3. asp.net webform 自定义分页控件

    做web开发一直用到分页控件,自己也动手实现了个,使用用户自定义控件. 翻页后数据加载使用委托,将具体实现放在在使用分页控件的页面进行注册. 有图有真相,给个直观的认识: 自定义分页控件前台代码: & ...

  4. C# DataGridView自定义分页控件

    好些日子不仔细写C#代码了,现在主要是Java项目,C#.Net相关项目不多了,有点手生了,以下代码不足之处望各位提出建议和批评. 近日闲来无事想研究一下自定义控件,虽然之前也看过,那也仅限于皮毛,粗 ...

  5. Mvc自定义分页控件

    MVC开发分页常常使用第三方控件,生成的分页HTML带有版权申明,虽然免费,但是总有的别扭.于是,某日,楼主闲来蛋疼,折腾了个自定义分页控件: 先来展示下效果图: 1>当分页不超过10页的时候, ...

  6. WPF管理系统自定义分页控件 - WPF特工队内部资料

    最近做一个演示的管理系统项目,需要用到分页控件,在网上找了很多,依然找到与UI模版匹配的,最后干脆自己写一个. 分页控件分析: 1.分页控件分简单显示和复杂显示两种: 2.包含上一页.下一页以及页码明 ...

  7. 浅尝辄止WPF自定义用户控件(实现颜色调制器)

    主要利用用户控件实现一个自定义的颜色调制控件,实现一个小小的功能,具体实现界面如下. 首先自己新建一个wpf的用户控件类,我就放在我的wpf项目的一个文件夹下面,因为是一个很小的东西,所以就没有用mv ...

  8. Winform自定义分页控件的实现

    实现效果 有点丑陋 但是功能是没问题的 测试过 实现思路 先创建一个用户控件 代码实现 public partial class PagerControl : UserControl { ; /// ...

  9. WPF 自定义Button控件及样式

    这次通过最近做的小例子说明一下自定义Button控件和样式. 实现的效果为:

随机推荐

  1. LOJ 2553 「CTSC2018」暴力写挂——边分治+虚树

    题目:https://loj.ac/problem/2553 第一棵树上的贡献就是链并,转化成 ( dep[ x ] + dep[ y ] + dis( x, y ) ) / 2 ,就可以在第一棵树上 ...

  2. jmeter ---断言持续时间(Duration to Assert )和断言文件大小

    jmeter ---断言持续时间(Duration to Assert )和断言文件大小 1.断言持续时间(Duration to Assert ) Duration to Assert -- 允许的 ...

  3. 【转】Linux安装HDF5及遇到的问题总结

    Linux安装HDF5及遇到的问题总结 转自: http://www.linuxdiyf.com/linux/26164.html   ubuntu版本:16.04.2 64位 从HDF官网(http ...

  4. Simple Logging Facade for Java 简单日志门面(Facade)

    SLF4J是为各种 loging APIs提供一个简单统一的接口,从而使得最终用户能够在部署的时候配置自己希望的loging APIs实现.Logging API实现既可以选择直接实现SLF4J接口的 ...

  5. python 多线程 并发socket实例

    sever side: import socketserver class MyTCPHandler(socketserver.BaseRequestHandler): def handle(self ...

  6. Debian下Netbeans编辑器字体锯齿现象

    第一步:到你netbeans安装目录下的etc目录下,找到netbeans.conf文件,打开准备编辑:第二步:在netbeans_default_options后面加上-J-Dawt.useSyst ...

  7. linux(ubuntu)下安装phantomjs

    1.安装phantomjs ubuntu下sudo apt-get install phantomjs下载的不能用 —-下载程序文件 到官网下载 1.安装phantomjs —-下载程序文件 wget ...

  8. C#使用MapReduce实现对分片数据的分组

    事由:mongodb已经进行数据分片,这样就不能使用一些方法就不能使用,例如eval,$group如果尝试使用mongodb会提示 Error: { , "errmsg" : &q ...

  9. Oracle 非归档--归档操作流程

    转载自链接  https://blog.csdn.net/u013611461/article/details/53558077 SQL> shutdown immediate; Databas ...

  10. keystone认证服务

    实验操作平台:OpenStack单节点操作 一.相关概念 1.认证(authentication) 认证是确认允许一个用户访问的进程 2.证书(credentials) 用于确认用户身份的数据 3.令 ...