273 lines
15 KiB
XML
273 lines
15 KiB
XML
<!-- 文件路径: /Themes/Generic.xaml -->
|
|
<ResourceDictionary
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:controls="clr-namespace:Melskin.Controls"
|
|
xmlns:converters="clr-namespace:Melskin.Converters"
|
|
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations">
|
|
|
|
<ResourceDictionary.MergedDictionaries>
|
|
<ResourceDictionary Source="/Melskin;component/Controls/ComboBox.xaml" />
|
|
<ResourceDictionary Source="/Melskin;component/Controls/TextBox.xaml" />
|
|
</ResourceDictionary.MergedDictionaries>
|
|
|
|
<!-- 页码按钮的样式 -->
|
|
<Style x:Key="EmbossPaginationButtonStyle" TargetType="Button">
|
|
<Setter Property="MinWidth" Value="32" />
|
|
<Setter Property="Height" Value="32" />
|
|
<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>
|
|
<decorations:EmbossBorder
|
|
x:Name="emboss"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
CornerRadius="4"
|
|
Foreground="{TemplateBinding Foreground}"
|
|
Intensity="0.4" />
|
|
<decorations:SlotBorder
|
|
x:Name="slot"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
CornerRadius="4"
|
|
Foreground="{TemplateBinding Foreground}"
|
|
Intensity=".4"
|
|
Visibility="Collapsed" />
|
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
|
|
</Grid>
|
|
<ControlTemplate.Triggers>
|
|
<DataTrigger Value="True">
|
|
<DataTrigger.Binding>
|
|
<MultiBinding Converter="{x:Static converters:ComparisionConverter.Instance}">
|
|
<Binding Path="Value" />
|
|
<!-- 来自按钮的 DataContext (PageItem.Value) -->
|
|
<Binding Path="CurrentPage" RelativeSource="{RelativeSource AncestorType=controls:Pagination}" />
|
|
</MultiBinding>
|
|
</DataTrigger.Binding>
|
|
<Setter TargetName="emboss" Property="Visibility" Value="Collapsed" />
|
|
<Setter TargetName="slot" Property="Visibility" Value="Visible" />
|
|
</DataTrigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
<Style.Triggers>
|
|
<!-- 核心: 当按钮的值等于控件的当前页时,改变样式 -->
|
|
<DataTrigger Value="True">
|
|
<DataTrigger.Binding>
|
|
<MultiBinding Converter="{x:Static converters:ComparisionConverter.Instance}">
|
|
<Binding Path="Value" />
|
|
<!-- 来自按钮的 DataContext (PageItem.Value) -->
|
|
<Binding Path="CurrentPage" RelativeSource="{RelativeSource AncestorType=controls:Pagination}" />
|
|
</MultiBinding>
|
|
</DataTrigger.Binding>
|
|
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
|
|
<!--<Setter Property="Foreground" Value="{DynamicResource TextAccentBrush}" />-->
|
|
<!--<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>
|
|
<Style x:Key="PaginationButtonStyle" TargetType="Button">
|
|
<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
|
|
x:Name="Border"
|
|
Background="{TemplateBinding Background}"
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
CornerRadius="4" />
|
|
<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}" />
|
|
|
|
<Setter TargetName="Border" Property="Background" Value="{DynamicResource ControlBackgroundSelectedBrush}" />
|
|
</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>
|
|
|
|
<!-- PaginationControl 的主模板 -->
|
|
<Style x:Key="EmbossPaginationStyle" TargetType="{x:Type controls:Pagination}">
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="{x:Type controls:Pagination}">
|
|
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
|
|
<!-- 页码按钮列表 -->
|
|
<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
|
|
Margin="8,0,0,0"
|
|
ItemsSource="{Binding PageSizeOptions, RelativeSource={RelativeSource TemplatedParent}}"
|
|
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"
|
|
VerticalAlignment="Center"
|
|
Orientation="Horizontal"
|
|
Visibility="{Binding ShowPageInput, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}">
|
|
<TextBlock VerticalAlignment="Center" Text="跳至" />
|
|
<TextBox
|
|
x:Name="PART_PageInputTextBox"
|
|
Width="50"
|
|
Margin="4,0"
|
|
HorizontalContentAlignment="Center"
|
|
Style="{StaticResource SlotTextBoxStyle}"
|
|
Text="{Binding CurrentPage, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
|
|
<TextBlock VerticalAlignment="Center" Text="页" />
|
|
</StackPanel>
|
|
</StackPanel>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
|
|
<Style TargetType="{x:Type controls:Pagination}">
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="{x:Type controls:Pagination}">
|
|
<StackPanel VerticalAlignment="Center" Orientation="Horizontal">
|
|
<!-- 页码按钮列表 -->
|
|
<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 PaginationButtonStyle}"
|
|
ToolTip="{Binding ToolTip}" />
|
|
</DataTemplate>
|
|
</ItemsControl.ItemTemplate>
|
|
</ItemsControl>
|
|
|
|
<!-- 页面尺寸选择器 -->
|
|
<ComboBox
|
|
Margin="8,0,0,0"
|
|
VerticalContentAlignment="Center"
|
|
ItemsSource="{Binding PageSizeOptions, RelativeSource={RelativeSource TemplatedParent}}"
|
|
SelectedItem="{Binding PageSize, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}">
|
|
<ComboBox.ItemTemplate>
|
|
<DataTemplate>
|
|
<TextBlock Text="{Binding StringFormat={}{0} 条/页}" />
|
|
</DataTemplate>
|
|
</ComboBox.ItemTemplate>
|
|
</ComboBox>
|
|
|
|
<!-- 跳转输入框 -->
|
|
<StackPanel
|
|
Margin="8,0,0,0"
|
|
VerticalAlignment="Center"
|
|
Orientation="Horizontal"
|
|
Visibility="{Binding ShowPageInput, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}">
|
|
<TextBlock VerticalAlignment="Center" Text="跳至" />
|
|
<TextBox
|
|
x:Name="PART_PageInputTextBox"
|
|
Width="50"
|
|
Margin="4,0"
|
|
HorizontalContentAlignment="Center"
|
|
VerticalContentAlignment="Center"
|
|
Text="{Binding CurrentPage, RelativeSource={RelativeSource TemplatedParent}, Mode=OneWay}" />
|
|
<TextBlock VerticalAlignment="Center" Text="页" />
|
|
</StackPanel>
|
|
</StackPanel>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
</ResourceDictionary> |