Files
ShrlAlgoToolkit/NeoUI/Melskin/Controls/Pagination.xaml

273 lines
15 KiB
Plaintext
Raw Normal View History

2025-08-20 12:10:35 +08:00
<!-- 文件路径: /Themes/Generic.xaml -->
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2026-01-02 17:30:41 +08:00
xmlns:controls="clr-namespace:Melskin.Controls"
xmlns:converters="clr-namespace:Melskin.Converters"
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations"
2026-01-02 17:30:30 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2025-08-20 12:10:35 +08:00
2025-12-28 11:47:54 +08:00
<ResourceDictionary.MergedDictionaries>
2026-01-02 17:30:41 +08:00
<ResourceDictionary Source="/Melskin;component/Controls/ComboBox.xaml" />
<ResourceDictionary Source="/Melskin;component/Controls/TextBox.xaml" />
2025-12-28 11:47:54 +08:00
</ResourceDictionary.MergedDictionaries>
2025-08-20 12:10:35 +08:00
<!-- 页码按钮的样式 -->
2026-01-02 17:30:30 +08:00
<Style TargetType="Button" x:Key="EmbossPaginationButtonStyle">
2025-08-20 12:10:35 +08:00
<Setter Property="MinWidth" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="Margin" Value="2,0" />
2025-08-26 21:33:20 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-20 12:10:35 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Focusable" Value="False" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
2025-09-04 22:39:00 +08:00
<decorations:EmbossBorder
2025-08-20 12:10:35 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
Foreground="{TemplateBinding Foreground}"
2026-01-02 17:30:30 +08:00
Intensity="0.4"
x:Name="emboss" />
2025-09-04 22:39:00 +08:00
<decorations:SlotBorder
2025-08-20 12:10:35 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
Foreground="{TemplateBinding Foreground}"
Intensity=".4"
2026-01-02 17:30:30 +08:00
Visibility="Collapsed"
x:Name="slot" />
2025-08-20 12:10:35 +08:00
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
<ControlTemplate.Triggers>
<DataTrigger Value="True">
<DataTrigger.Binding>
2025-09-04 22:39:00 +08:00
<MultiBinding Converter="{x:Static converters:ComparisionConverter.Instance}">
2025-08-20 12:10:35 +08:00
<Binding Path="Value" />
<!-- 来自按钮的 DataContext (PageItem.Value) -->
2025-10-10 11:19:58 +08:00
<Binding Path="CurrentPage" RelativeSource="{RelativeSource AncestorType=controls:Pagination}" />
2025-08-20 12:10:35 +08:00
</MultiBinding>
</DataTrigger.Binding>
2026-01-02 17:30:30 +08:00
<Setter Property="Visibility" TargetName="emboss" Value="Collapsed" />
<Setter Property="Visibility" TargetName="slot" Value="Visible" />
2025-08-20 12:10:35 +08:00
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<!-- 核心: 当按钮的值等于控件的当前页时,改变样式 -->
<DataTrigger Value="True">
<DataTrigger.Binding>
2025-09-04 22:39:00 +08:00
<MultiBinding Converter="{x:Static converters:ComparisionConverter.Instance}">
2025-08-20 12:10:35 +08:00
<Binding Path="Value" />
<!-- 来自按钮的 DataContext (PageItem.Value) -->
2025-10-10 11:19:58 +08:00
<Binding Path="CurrentPage" RelativeSource="{RelativeSource AncestorType=controls:Pagination}" />
2025-08-20 12:10:35 +08:00
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
2025-09-12 09:55:36 +08:00
<!--<Setter Property="Foreground" Value="{DynamicResource TextAccentBrush}" />-->
2025-08-20 12:10:35 +08:00
<!--<Setter Property="Background" Value="{DynamicResource PrimaryNormalBrush}" />-->
</DataTrigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.6" />
<Setter Property="Cursor" Value="No" />
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
</Trigger>
</Style.Triggers>
</Style>
2026-01-02 17:30:30 +08:00
<Style TargetType="Button" x:Key="PaginationButtonStyle">
2025-12-23 21:35:54 +08:00
<Setter Property="MinWidth" Value="34" />
<Setter Property="MinHeight" Value="34" />
<Setter Property="Margin" Value="2,0" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Focusable" Value="False" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
2026-01-02 17:30:30 +08:00
CornerRadius="4"
x:Name="Border" />
2025-12-23 21:35:54 +08:00
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Grid>
<ControlTemplate.Triggers>
<!-- 核心: 当按钮的值等于控件的当前页时,改变样式 -->
<DataTrigger Value="True">
<DataTrigger.Binding>
<MultiBinding Converter="{x:Static converters:ComparisionConverter.Instance}">
<!-- 来自按钮的 DataContext (PageItem.Value) -->
<Binding Path="Value" />
<Binding Path="CurrentPage" RelativeSource="{RelativeSource AncestorType=controls:Pagination}" />
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
2026-01-02 17:30:30 +08:00
<Setter Property="Background" TargetName="Border" Value="{DynamicResource ControlBackgroundSelectedBrush}" />
2025-12-23 21:35:54 +08:00
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<DataTrigger Value="True">
<DataTrigger.Binding>
<MultiBinding Converter="{x:Static converters:ComparisionConverter.Instance}">
<Binding Path="Value" />
<Binding Path="CurrentPage" RelativeSource="{RelativeSource AncestorType=controls:Pagination}" />
</MultiBinding>
</DataTrigger.Binding>
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundSelectedBrush}" />
</DataTrigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.6" />
<Setter Property="Cursor" Value="No" />
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
</Trigger>
</Style.Triggers>
</Style>
2025-08-20 12:10:35 +08:00
<!-- PaginationControl 的主模板 -->
2026-01-02 17:30:30 +08:00
<Style TargetType="{x:Type controls:Pagination}" x:Key="EmbossPaginationStyle">
2025-12-28 11:47:54 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Pagination}">
2026-01-02 17:30:30 +08:00
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
2025-12-28 11:47:54 +08:00
<!-- 页码按钮列表 -->
<ItemsControl ItemsSource="{Binding PageItems, RelativeSource={RelativeSource TemplatedParent}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type controls:PageItem}">
<Button
Content="{Binding Text}"
IsEnabled="{Binding IsEnabled}"
Style="{StaticResource EmbossPaginationButtonStyle}"
ToolTip="{Binding ToolTip}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<!-- 页面尺寸选择器 -->
<ComboBox
ItemsSource="{Binding PageSizeOptions, RelativeSource={RelativeSource TemplatedParent}}"
2026-01-02 17:30:30 +08:00
Margin="8,0,0,0"
2025-12-28 11:47:54 +08:00
SelectedItem="{Binding PageSize, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
Style="{StaticResource FloatComboBoxStyle}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding StringFormat={}{0} 条/页}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<!-- 跳转输入框 -->
<StackPanel
Margin="8,0,0,0"
Orientation="Horizontal"
2026-01-02 17:30:30 +08:00
VerticalAlignment="Center"
2025-12-28 11:47:54 +08:00
Visibility="{Binding ShowPageInput, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}">
2026-01-02 17:30:30 +08:00
<TextBlock Text="跳至" VerticalAlignment="Center" />
2025-12-28 11:47:54 +08:00
<TextBox
HorizontalContentAlignment="Center"
2026-01-02 17:30:30 +08:00
Margin="4,0"
2025-12-28 11:47:54 +08:00
Style="{StaticResource SlotTextBoxStyle}"
2026-01-02 17:30:30 +08:00
Text="{Binding CurrentPage, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
Width="50"
x:Name="PART_PageInputTextBox" />
<TextBlock Text="页" VerticalAlignment="Center" />
2025-12-28 11:47:54 +08:00
</StackPanel>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2025-10-10 11:19:58 +08:00
<Style TargetType="{x:Type controls:Pagination}">
2025-08-20 12:10:35 +08:00
<Setter Property="Template">
<Setter.Value>
2025-10-10 11:19:58 +08:00
<ControlTemplate TargetType="{x:Type controls:Pagination}">
2026-01-02 17:30:30 +08:00
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
2025-08-20 12:10:35 +08:00
<!-- 页码按钮列表 -->
<ItemsControl ItemsSource="{Binding PageItems, RelativeSource={RelativeSource TemplatedParent}}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type controls:PageItem}">
2025-08-20 12:10:35 +08:00
<Button
Content="{Binding Text}"
IsEnabled="{Binding IsEnabled}"
Style="{StaticResource PaginationButtonStyle}"
ToolTip="{Binding ToolTip}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<!-- 页面尺寸选择器 -->
<ComboBox
2025-12-23 21:35:54 +08:00
ItemsSource="{Binding PageSizeOptions, RelativeSource={RelativeSource TemplatedParent}}"
2026-01-02 17:30:30 +08:00
Margin="8,0,0,0"
SelectedItem="{Binding PageSize, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
VerticalContentAlignment="Center">
2025-08-20 12:10:35 +08:00
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding StringFormat={}{0} 条/页}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<!-- 跳转输入框 -->
<StackPanel
Margin="8,0,0,0"
2025-12-23 21:35:54 +08:00
Orientation="Horizontal"
2026-01-02 17:30:30 +08:00
VerticalAlignment="Center"
2025-09-04 22:39:00 +08:00
Visibility="{Binding ShowPageInput, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}">
2026-01-02 17:30:30 +08:00
<TextBlock Text="跳至" VerticalAlignment="Center" />
2025-08-20 12:10:35 +08:00
<TextBox
2025-12-23 21:35:54 +08:00
HorizontalContentAlignment="Center"
2026-01-02 17:30:30 +08:00
Margin="4,0"
Text="{Binding CurrentPage, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}"
2025-08-20 12:10:35 +08:00
VerticalContentAlignment="Center"
2026-01-02 17:30:30 +08:00
Width="50"
x:Name="PART_PageInputTextBox" />
<TextBlock Text="页" VerticalAlignment="Center" />
2025-08-20 12:10:35 +08:00
</StackPanel>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>