




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
第WPF實(shí)現(xiàn)列表分頁(yè)控件的示例代碼項(xiàng)目使用MIT開(kāi)源許可協(xié)議。
新建Pagination自定義控件繼承自Control。
正常模式分頁(yè)在外部套Grid分為0-5列:
Grid.Column0總頁(yè)數(shù)共多少300條。Grid.Column1輸入每頁(yè)顯示多少10條。Grid.Column2上一頁(yè)按鈕。Grid.Column3所有頁(yè)碼按鈕此處使用ListBox。Grid.Column4下一頁(yè)按鈕。Grid.Column5跳轉(zhuǎn)頁(yè)1碼輸入框。
精簡(jiǎn)模式分頁(yè)在外部套Grid分為0-9列:
Grid.Column0總頁(yè)數(shù)共多少300條。Grid.Column2輸入每頁(yè)顯示多少10條。Grid.Column3條/頁(yè)。Grid.Column5上一頁(yè)按鈕。Grid.Column7跳轉(zhuǎn)頁(yè)1碼輸入框。Grid.Column9下一頁(yè)按鈕。
每頁(yè)顯示與跳轉(zhuǎn)頁(yè)碼數(shù)控制只允許輸入數(shù)字,不允許粘貼。
實(shí)現(xiàn)代碼
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="10"/
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="10"/
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="5"/
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="5"/
ColumnDefinition
Width="Auto"/
1)Pagination.cs如下:
using
System;
using
System.Collections.Generic;
using
System.Linq;
using
System.Windows;
using
System.Windows.Controls;
using
System.Windows.Input;
using
WPFDevelopers.Helpers;
namespace
WPFDevelopers.Controls
[TemplatePart(Name
=
CountPerPageTextBoxTemplateName,
Type
=
typeof(TextBox))]
[TemplatePart(Name
=
JustPageTextBoxTemplateName,
Type
=
typeof(TextBox))]
[TemplatePart(Name
=
ListBoxTemplateName,
Type
=
typeof(ListBox))]
public
class
Pagination
:
Control
{
private
const
string
CountPerPageTextBoxTemplateName
=
"PART_CountPerPageTextBox";
private
const
string
JustPageTextBoxTemplateName
=
"PART_JumpPageTextBox";
private
const
string
ListBoxTemplateName
=
"PART_ListBox";
private
const
string
Ellipsis
=
"···";
private
static
readonly
Type
_typeofSelf
=
typeof(Pagination);
private
TextBox
_countPerPageTextBox;
private
TextBox
_jumpPageTextBox;
private
ListBox
_listBox;
static
Pagination()
{
InitializeCommands();
DefaultStyleKeyProperty.OverrideMetadata(_typeofSelf,
new
FrameworkPropertyMetadata(_typeofSelf));
}
#region
Override
public
override
void
OnApplyTemplate()
{
base.OnApplyTemplate();
UnsubscribeEvents();
_countPerPageTextBox
=
GetTemplateChild(CountPerPageTextBoxTemplateName)
as
TextBox;
if
(_countPerPageTextBox
!=
null)
{
_countPerPageTextBox.ContextMenu
=
null;
_countPerPageTextBox.PreviewTextInput
+=
_countPerPageTextBox_PreviewTextInput;
_countPerPageTextBox.PreviewKeyDown
+=
_countPerPageTextBox_PreviewKeyDown;
}
_jumpPageTextBox
=
GetTemplateChild(JustPageTextBoxTemplateName)
as
TextBox;
if
(_jumpPageTextBox
!=
null)
{
_jumpPageTextBox.ContextMenu
=
null;
_jumpPageTextBox.PreviewTextInput
+=
_countPerPageTextBox_PreviewTextInput;
_jumpPageTextBox.PreviewKeyDown
+=
_countPerPageTextBox_PreviewKeyDown;
}
_listBox
=
GetTemplateChild(ListBoxTemplateName)
as
ListBox;
Init();
SubscribeEvents();
}
private
void
_countPerPageTextBox_PreviewKeyDown(object
sender,
KeyEventArgs
e)
{
if
(Key.Space
==
e.Key
||
Key.V
==
e.Key
e.KeyboardDevice.Modifiers
==
ModifierKeys.Control)
e.Handled
=
true;
}
private
void
_countPerPageTextBox_PreviewTextInput(object
sender,
TextCompositionEventArgs
e)
{
e.Handled
=
ControlsHelper.IsNumber(e.Text);
}
#endregion
#region
Command
private
static
void
InitializeCommands()
{
PrevCommand
=
new
RoutedCommand("Prev",
_typeofSelf);
NextCommand
=
new
RoutedCommand("Next",
_typeofSelf);
CommandManager.RegisterClassCommandBinding(_typeofSelf,
new
CommandBinding(PrevCommand,
OnPrevCommand,
OnCanPrevCommand));
CommandManager.RegisterClassCommandBinding(_typeofSelf,
new
CommandBinding(NextCommand,
OnNextCommand,
OnCanNextCommand));
}
public
static
RoutedCommand
PrevCommand
{
get;
private
set;
}
public
static
RoutedCommand
NextCommand
{
get;
private
set;
}
private
static
void
OnPrevCommand(object
sender,
RoutedEventArgs
e)
{
var
ctrl
=
sender
as
Pagination;
ctrl.Current--;
}
private
static
void
OnCanPrevCommand(object
sender,
CanExecuteRoutedEventArgs
e)
{
var
ctrl
=
sender
as
Pagination;
e.CanExecute
=
ctrl.Current
}
private
static
void
OnNextCommand(object
sender,
RoutedEventArgs
e)
{
var
ctrl
=
sender
as
Pagination;
ctrl.Current++;
}
private
static
void
OnCanNextCommand(object
sender,
CanExecuteRoutedEventArgs
e)
{
var
ctrl
=
sender
as
Pagination;
e.CanExecute
=
ctrl.Current
ctrl.PageCount;
}
#endregion
#region
Properties
private
static
readonly
DependencyPropertyKey
PagesPropertyKey
=
DependencyProperty.RegisterReadOnly("Pages",
typeof(IEnumerablestring),
_typeofSelf,
new
PropertyMetadata(null));
public
static
readonly
DependencyProperty
PagesProperty
=
PagesPropertyKey.DependencyProperty;
public
IEnumerablestring
Pages
=
(IEnumerablestring)
GetValue(PagesProperty);
private
static
readonly
DependencyPropertyKey
PageCountPropertyKey
=
DependencyProperty.RegisterReadOnly("PageCount",
typeof(int),
_typeofSelf,
new
PropertyMetadata(1,
OnPageCountPropertyChanged));
public
static
readonly
DependencyProperty
PageCountProperty
=
PageCountPropertyKey.DependencyProperty;
public
int
PageCount
=
(int)
GetValue(PageCountProperty);
private
static
void
OnPageCountPropertyChanged(DependencyObject
d,
DependencyPropertyChangedEventArgs
e)
{
var
ctrl
=
d
as
Pagination;
var
pageCount
=
(int)
e.NewValue;
/*
if
(ctrl._jumpPageTextBox
!=
null)
ctrl._jumpPageTextBox.Maximum
=
pageCount;
*/
}
public
static
readonly
DependencyProperty
IsLiteProperty
=
DependencyProperty.Register("IsLite",
typeof(bool),
_typeofSelf,
new
PropertyMetadata(false));
public
bool
IsLite
{
get
=
(bool)
GetValue(IsLiteProperty);
set
=
SetValue(IsLiteProperty,
value);
}
public
static
readonly
DependencyProperty
CountProperty
=
DependencyProperty.Register("Count",
typeof(int),
_typeofSelf,
new
PropertyMetadata(0,
OnCountPropertyChanged,
CoerceCount));
public
int
Count
{
get
=
(int)
GetValue(CountProperty);
set
=
SetValue(CountProperty,
value);
}
private
static
object
CoerceCount(DependencyObject
d,
object
value)
{
var
count
=
(int)
value;
return
Math.Max(count,
0);
}
private
static
void
OnCountPropertyChanged(DependencyObject
d,
DependencyPropertyChangedEventArgs
e)
{
var
ctrl
=
d
as
Pagination;
var
count
=
(int)
e.NewValue;
ctrl.SetValue(PageCountPropertyKey,
(int)
Math.Ceiling(count
*
1.0
/
ctrl.CountPerPage));
ctrl.UpdatePages();
}
public
static
readonly
DependencyProperty
CountPerPageProperty
=
DependencyProperty.Register("CountPerPage",
typeof(int),
_typeofSelf,
new
PropertyMetadata(50,
OnCountPerPagePropertyChanged,
CoerceCountPerPage));
public
int
CountPerPage
{
get
=
(int)
GetValue(CountPerPageProperty);
set
=
SetValue(CountPerPageProperty,
value);
}
private
static
object
CoerceCountPerPage(DependencyObject
d,
object
value)
{
var
countPerPage
=
(int)
value;
return
Math.Max(countPerPage,
1);
}
private
static
void
OnCountPerPagePropertyChanged(DependencyObject
d,
DependencyPropertyChangedEventArgs
e)
{
var
ctrl
=
d
as
Pagination;
var
countPerPage
=
(int)
e.NewValue;
if
(ctrl._countPerPageTextBox
!=
null)
ctrl._countPerPageTextBox.Text
=
countPerPage.ToString();
ctrl.SetValue(PageCountPropertyKey,
(int)
Math.Ceiling(ctrl.Count
*
1.0
/
countPerPage));
if
(ctrl.Current
!=
1)
ctrl.Current
=
1;
else
ctrl.UpdatePages();
}
public
static
readonly
DependencyProperty
CurrentProperty
=
DependencyProperty.Register("Current",
typeof(int),
_typeofSelf,
new
PropertyMetadata(1,
OnCurrentPropertyChanged,
CoerceCurrent));
public
int
Current
{
get
=
(int)
GetValue(CurrentProperty);
set
=
SetValue(CurrentProperty,
value);
}
private
static
object
CoerceCurrent(DependencyObject
d,
object
value)
{
var
current
=
(int)
value;
var
ctrl
=
d
as
Pagination;
return
Math.Max(current,
1);
}
private
static
void
OnCurrentPropertyChanged(DependencyObject
d,
DependencyPropertyChangedEventArgs
e)
{
var
ctrl
=
d
as
Pagination;
var
current
=
(int)
e.NewValue;
if
(ctrl._listBox
!=
null)
ctrl._listBox.SelectedItem
=
current.ToString();
if
(ctrl._jumpPageTextBox
!=
null)
ctrl._jumpPageTextBox.Text
=
current.ToString();
ctrl.UpdatePages();
}
#endregion
#region
Event
///
summary
///
分頁(yè)
///
/summary
private
void
OnCountPerPageTextBoxChanged(object
sender,
TextChangedEventArgs
e)
{
if
(int.TryParse(_countPerPageTextBox.Text,
out
var
_ountPerPage))
CountPerPage
=
_ountPerPage;
}
///
summary
///
跳轉(zhuǎn)頁(yè)
///
/summary
private
void
OnJumpPageTextBoxChanged(object
sender,
TextChangedEventArgs
e)
{
if
(int.TryParse(_jumpPageTextBox.Text,
out
var
_current))
Current
=
_current;
}
///
summary
///
選擇頁(yè)
///
/summary
private
void
OnSelectionChanged(object
sender,
SelectionChangedEventArgs
e)
{
if
(_listBox.SelectedItem
==
null)
return;
Current
=
int.Parse(_listBox.SelectedItem.ToString());
}
#endregion
#region
Private
private
void
Init()
{
SetValue(PageCountPropertyKey,
(int)
Math.Ceiling(Count
*
1.0
/
CountPerPage));
_jumpPageTextBox.Text
=
Current.ToString();
//_jumpPageTextBox.Maximum
=
PageCount;
_countPerPageTextBox.Text
=
CountPerPage.ToString();
if
(_listBox
!=
null)
_listBox.SelectedItem
=
Current.ToString();
}
private
void
UnsubscribeEvents()
{
if
(_countPerPageTextBox
!=
null)
_countPerPageTextBox.TextChanged
-=
OnCountPerPageTextBoxChanged;
if
(_jumpPageTextBox
!=
null)
_jumpPageTextBox.TextChanged
-=
OnJumpPageTextBoxChanged;
if
(_listBox
!=
null)
_listBox.SelectionChanged
-=
OnSelectionChanged;
}
private
void
SubscribeEvents()
{
if
(_countPerPageTextBox
!=
null)
_countPerPageTextBox.TextChanged
+=
OnCountPerPageTextBoxChanged;
if
(_jumpPageTextBox
!=
null)
_jumpPageTextBox.TextChanged
+=
OnJumpPageTextBoxChanged;
if
(_listBox
!=
null)
_listBox.SelectionChanged
+=
OnSelectionChanged;
}
private
void
UpdatePages()
{
SetValue(PagesPropertyKey,
GetPagers(Count,
Current));
if
(_listBox
!=
null
_listBox.SelectedItem
==
null)
_listBox.SelectedItem
=
Current.ToString();
}
private
IEnumerablestring
GetPagers(int
count,
int
current)
{
if
(count
==
0)
return
null;
if
(PageCount
=
7)
return
Enumerable.Range(1,
PageCount).Select(p
=
p.ToString()).ToArray();
if
(current
=
4)
return
new[]
{"1",
"2",
"3",
"4",
"5",
Ellipsis,
PageCount.ToString()};
if
(current
=
PageCount
-
3)
return
new[]
{
"1",
Ellipsis,
(PageCount
-
4).ToString(),
(PageCount
-
3).ToString(),
(PageCount
-
2).ToString(),
(PageCount
-
1).ToString(),
PageCount.ToString()
};
return
new[]
{
"1",
Ellipsis,
(current
-
1).ToString(),
current.ToString(),
(current
+
1).ToString(),
Ellipsis,
PageCount.ToString()
};
}
#endregion
}
2)Pagination.xaml如下:
ResourceDictionary
xmlns="/winfx/2006/xaml/presentation"
xmlns:x="/winfx/2006/xaml"
xmlns:input="clr-namespace:System.Windows.Input;assembly=PresentationCore"
xmlns:helpers="clr-namespace:WPFDevelopers.Helpers"
xmlns:controls="clr-namespace:WPFDevelopers.Controls"
ResourceDictionary.MergedDictionaries
ResourceDictionary
Source="Basic/ControlBasic.xaml"/
/ResourceDictionary.MergedDictionaries
Style
x:Key="PageListBoxStyleKey"
TargetType="{x:Type
ListBox}"
BasedOn="{StaticResource
ControlBasicStyle}"
Setter
Property="Background"
Value="Transparent"/
Setter
Property="BorderThickness"
Value="0"/
Setter
Property="Padding"
Value="0"/
Setter
Property="Template"
Setter.Value
ControlTemplate
TargetType="{x:Type
ListBox}"
Border
BorderBrush="{TemplateBinding
BorderBrush}"
BorderThickness="{TemplateBinding
BorderThickness}"
Background="{TemplateBinding
Background}"
SnapsToDevicePixels="True"
ScrollViewer
Focusable="False"
Padding="{TemplateBinding
Padding}"
ItemsPresenter
SnapsToDevicePixels="{TemplateBinding
SnapsToDevicePixels}"/
/ScrollViewer
/Border
ControlTemplate.Triggers
Trigger
Property="IsGrouping"
Value="True"
Setter
Property="ScrollViewer.CanContentScroll"
Value="False"/
/Trigger
/ControlTemplate.Triggers
/ControlTemplate
/Setter.Value
/Setter
/Style
Style
x:Key="PageListBoxItemStyleKey"
TargetType="{x:Type
ListBoxItem}"
BasedOn="{StaticResource
ControlBasicStyle}"
Setter
Property="MinWidth"
Value="32"/
Setter
Property="Cursor"
Value="Hand"/
Setter
Property="HorizontalContentAlignment"
Value="Center"/
Setter
Property="VerticalContentAlignment"
Value="Center"/
Setter
Property="helpers:ElementHelper.CornerRadius"
Value="3"/
Setter
Property="BorderThickness"
Value="1"/
Setter
Property="Padding"
Value="5,0"/
Setter
Property="Margin"
Value="3,0"/
Setter
Property="Background"
Value="{DynamicResource
BackgroundSolidColorBrush}"/
Setter
Property="BorderBrush"
Value="{DynamicResource
BaseSolidColorBrush}"/
Setter
Property="Template"
Setter.Value
ControlTemplate
TargetType="{x:Type
ListBoxItem}"
Border
SnapsToDevicePixels="True"
Background="{TemplateBinding
Background}"
BorderThickness="{TemplateBinding
BorderThickness}"
BorderBrush="{TemplateBinding
BorderBrush}"
Padding="{TemplateBinding
Padding}"
CornerRadius="{Binding
Path=(helpers:ElementHelper.CornerRadius),RelativeSource={RelativeSource
TemplatedParent}}"
ContentPresenter
x:Name="PART_ContentPresenter"
HorizontalAlignment="{TemplateBinding
HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding
VerticalContentAlignment}"
RecognizesAccessKey="True"
TextElement.Foreground="{TemplateBinding
Foreground}"/
/Border
/ControlTemplate
/Setter.Value
/Setter
Style.Triggers
DataTrigger
Binding="{Binding
.}"
Value="···"
Setter
Property="IsEnabled"
Value="False"/
Setter
Property="FontWeight"
Value="Bold"/
/DataTrigger
Trigger
Property="IsMouseOver"
Value="True"
Setter
Property="BorderBrush"
Value="{DynamicResource
DefaultBorderBrushSolidColorBrush}"/
Setter
Property="Background"
Value="{DynamicResource
DefaultBackgroundSolidColorBrush}"/
Setter
Property="Foreground"
Value="{DynamicResource
PrimaryNormalSolidColorBrush}"/
/Trigger
Trigger
Property="IsSelected"
Value="True"
Setter
Property="Background"
Value="{DynamicResource
PrimaryPressedSolidColorBrush}"/
Setter
Property="TextElement.Foreground"
Value="{DynamicResource
WindowForegroundColorBrush}"/
/Trigger
/Style.Triggers
/Style
ControlTemplate
x:Key="LitePagerControlTemplate"
TargetType="{x:Type
controls:Pagination}"
Border
Background="{TemplateBinding
Background}"
BorderBrush="{TemplateBinding
BorderBrush}"
BorderThickness="{TemplateBinding
BorderThickness}"
Padding="{TemplateBinding
Padding}"
Grid
Grid.ColumnDefinitions
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="10"/
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="10"/
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="5"/
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="5"/
ColumnDefinition
Width="Auto"/
/Grid.ColumnDefinitions
TextBlock
VerticalAlignment="Center"
Text="{Binding
Count,StringFormat=共
{0}
條,RelativeSource={RelativeSource
TemplatedParent}}"/
TextBox
Grid.Column="2"
x:Name="PART_CountPerPageTextBox"
TextAlignment="Center"
VerticalContentAlignment="Center"
Width="60"
MinWidth="0"
input:InputMethod.IsInputMethodEnabled="False"/
TextBlock
Grid.Column="3"
Text="
條
/
頁(yè)"
VerticalAlignment="Center"/
Button
Grid.Column="5"
Command="{x:Static
controls:Pagination.PrevCommand}"
Path
Width="7"
Height="10"
Stretch="Fill"
Fill="{Binding
Foreground,RelativeSource={RelativeSource
AncestorType=Button}}"
Data="{StaticResource
PathPrevious}"/
/Button
TextBox
Grid.Column="7"
x:Name="PART_JumpPageTextBox"
TextAlignment="Center"
VerticalContentAlignment="Center"
Width="60"
MinWidth="0"
TextBox.ToolTip
TextBlock
TextBlock.Text
MultiBinding
StringFormat="{}{0}/{1}"
Binding
Path="Current"
RelativeSource="{RelativeSource
TemplatedParent}"/
Binding
Path="PageCount"
RelativeSource="{RelativeSource
TemplatedParent}"/
/MultiBinding
/TextBlock.Text
/TextBlock
/TextBox.ToolTip
/TextBox
Button
Grid.Column="9"
Command="{x:Static
controls:Pagination.NextCommand}"
Path
Width="7"
Height="10"
Stretch="Fill"
Fill="{Binding
Foreground,RelativeSource={RelativeSource
AncestorType=Button}}"
Data="{StaticResource
PathNext}"/
/Button
/Grid
/Border
/ControlTemplate
Style
TargetType="{x:Type
controls:Pagination}"
BasedOn="{StaticResource
ControlBasicStyle}"
Setter
Property="Template"
Setter.Value
ControlTemplate
TargetType="{x:Type
controls:Pagination}"
Border
Background="{TemplateBinding
Background}"
BorderBrush="{TemplateBinding
BorderBrush}"
BorderThickness="{TemplateBinding
BorderThickness}"
Padding="{TemplateBinding
Padding}"
Grid
Grid.ColumnDefinitions
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="*"/
ColumnDefinition
Width="Auto"/
ColumnDefinition
Width="Auto"/
/Grid.ColumnDefinitions
TextBlock
Margin="0,0,15,0"
VerticalAlignment="Center"
Text="{Binding
Count,StringFormat=共
{0}
條,RelativeSource={RelativeSource
TemplatedParent}}"/
StackPanel
Grid.Column="1"
Orientation="Horizontal"
Margin="0,0,15,0"
TextBlock
Text="每頁(yè)
"
VerticalAlignment="Center"/
TextBox
x:Name="PART_CountPerPageTextBox"
TextAlignment="Center"
Width="60"
MinWidth="0"
VerticalContentAlignment="Center"
FontSize="{TemplateBinding
FontSize}"
input:InputMethod.IsInputMethodEnabled="False"/
TextBlock
Text="
條"
VerticalAlignment="Center"/
/StackPanel
Button
Grid.Column="2"
Command="{x:Static
controls:Pagination.PrevCommand}"
Path
Width="7"
Height="10"
Stretch="Fill"
Fill="{Binding
Foreground,RelativeSource={RelativeSource
AncestorType=Button}}"
Data="{StaticResource
PathPrevious}"/
/Button
ListBox
x:Name="PART_ListBox"
Grid.Column="3"
SelectedIndex="0"
Margin="5,0"
ItemsSource="{TemplateBinding
Pages}"
ItemContainer
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
ScrollViewer.VerticalScrollBarVisibility="Hidden"
ListBox.ItemsPanel
ItemsPanelTemplate
UniformGrid
Rows="1"/
/ItemsPanelTemplate
/ListBox.ItemsPanel
/ListBox
Button
Grid.Column="4"
Command="{x:Static
controls:Pagination.NextCommand}"
Path
Width="7"
Height="10"
Stretch="Fill"
Fill="{Binding
Foreground,RelativeSource={RelativeSource
AncestorType=Button}}"
Data="{StaticResource
PathNext}"/
/Button
StackPanel
Grid.Column="5"
Orientation="Horizontal"
TextBlock
Text="
前往
"
VerticalAlignment="Center"/
TextBox
x:Name="PART_JumpPageTextBox"
TextAlignment="Center"
ContextMenu="{x:Null}"
Width="60"
VerticalContentAlignment="Center"
MinWidth="0"
FontSize="{TemplateBinding
FontSize}"
/
TextBlock
Text="
頁(yè)"
VerticalAlignment="Center"/
/StackPanel
/Grid
/Border
/ControlTemplate
/Setter.Value
/Setter
Style.Triggers
Trigger
Property="IsLite"
Value="true"
Setter
Property="Template"
Value="{StaticResource
LitePagerControlTemplate}"/
/Trigger
/Style.Triggers
/Style
/ResourceDictionary
3)創(chuàng)建PaginationExampleVM.cs如下:
using
System.Collections.Generic;
using
System.Collections.ObjectModel;
using
System.Linq;
namespace
WPFDevelopers.Samples.ViewModels
public
class
PaginationExampleVM
:
ViewModelBase
{
private
Listint
_sourceList
=
new
Listint
public
PaginationExampleVM()
{
_sourceList.AddRange(Enumerable.Range(1,
300));
Count
=
300;
CurrentPageChanged();
}
public
ObservableCollectionint
PaginationCollection
{
get;
set;
}
=
new
ObservableCollectionint
private
int
_count;
public
int
Count
{
get
{
return
_count;
}
set
{
_count
=
value;
this.NotifyPropertyChange("Count");
CurrentPageChanged();
}
}
private
int
_countPerPage
=
10;
public
int
CountPerPage
{
get
{
return
_countPerPage;
}
set
{
_countPerPage
=
value;
this.NotifyPropertyChange("CountPerPage");
CurrentPageChanged();
}
}
private
int
_current
=
1;
public
int
Current
{
get
{
return
_current;
}
set
{
_current
=
value;
this.NotifyPropertyChange("Current");
CurrentPageChanged();
}
}
private
void
CurrentPageChanged()
{
PaginationCollection.Clear();
foreach
(var
i
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 合同變更內(nèi)容協(xié)議書(shū)
- 情侶戀愛(ài)合同協(xié)議書(shū)
- 合同協(xié)議書(shū)封面字體大小
- 運(yùn)費(fèi)合同協(xié)議書(shū)
- 易地扶貧搬遷合同協(xié)議書(shū)
- 歷年中考英語(yǔ)2017內(nèi)蒙古包頭英語(yǔ)試卷+答案+解析
- 2025年制造業(yè)綠色供應(yīng)鏈與綠色供應(yīng)鏈管理技術(shù)創(chuàng)新與綠色產(chǎn)業(yè)競(jìng)爭(zhēng)力提升報(bào)告
- 征地合同協(xié)議書(shū)
- 餐飲服務(wù)合同終止協(xié)議書(shū)
- 家具公司合作協(xié)議書(shū)合同
- 《現(xiàn)代企業(yè)管理學(xué)》本科教材
- 光伏組件維修合同范本
- 工業(yè)園區(qū)消防安全管理制度
- 2024年福建省公務(wù)員錄用考試《行測(cè)》真題及答案解析
- 慢阻肺康復(fù)治療病例匯報(bào)
- 氫氧化鈉購(gòu)銷(xiāo)
- 醫(yī)療器械供應(yīng)商合作管理制度
- 2024年中級(jí)電工考前必刷必練題庫(kù)500題(含真題、必會(huì)題)
- DB11-T 1832.7-2022 建筑工程施工工藝規(guī)程 第7部分:建筑地面工程
- 湖北省武漢市騰云聯(lián)盟2023-2024學(xué)年高二下學(xué)期5月聯(lián)考化學(xué)試卷
- 《PLC應(yīng)用技術(shù)(西門(mén)子S7-1200)第二版》全套教學(xué)課件
評(píng)論
0/150
提交評(píng)論