Pagination.xaml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:hc="clr-namespace:HandyControl.Controls"
  4. xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
  5. xmlns:system="clr-namespace:System;assembly=mscorlib"
  6. xmlns:lang="clr-namespace:HandyControl.Properties.Langs"
  7. xmlns:ex="clr-namespace:HandyControl.Tools.Extension">
  8. <Style x:Key="PaginationButtonStyle" BasedOn="{StaticResource BaseStyle}" TargetType="RadioButton">
  9. <Setter Property="GroupName" Value="1"/>
  10. <Setter Property="MinWidth" Value="30"/>
  11. <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
  12. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  13. <Setter Property="BorderThickness" Value="1"/>
  14. <Setter Property="VerticalAlignment" Value="Center"/>
  15. <Setter Property="VerticalContentAlignment" Value="Center"/>
  16. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  17. <Setter Property="hc:BorderElement.CornerRadius" Value="0"/>
  18. <Setter Property="Height" Value="{StaticResource DefaultControlHeight}"/>
  19. <Setter Property="Padding" Value="10,0"/>
  20. <Setter Property="Margin" Value="-1,0,0,0"/>
  21. <Setter Property="Template">
  22. <Setter.Value>
  23. <ControlTemplate TargetType="RadioButton">
  24. <Border x:Name="BorderRoot" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
  25. <StackPanel Orientation="Horizontal" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Margin="{TemplateBinding Padding}">
  26. <Path x:Name="PathMain" Width="{TemplateBinding hc:IconElement.Width}" Height="{TemplateBinding hc:IconElement.Height}" Fill="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Stretch="Uniform" Data="{TemplateBinding hc:IconElement.Geometry}"/>
  27. <ContentPresenter x:Name="contentPresenter" RecognizesAccessKey="True" VerticalAlignment="Center" Margin="6,0,0,0" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
  28. </StackPanel>
  29. </Border>
  30. <ControlTemplate.Triggers>
  31. <Trigger Property="IsMouseOver" Value="True">
  32. <Setter Property="TextElement.Foreground" Value="{DynamicResource PrimaryBrush}" TargetName="contentPresenter"/>
  33. </Trigger>
  34. <Trigger Property="IsChecked" Value="true">
  35. <Setter Property="BorderBrush" Value="{Binding Path=(hc:VisualElement.HighlightBorderBrush),RelativeSource={RelativeSource TemplatedParent}}" TargetName="BorderRoot"/>
  36. <Setter Property="Background" Value="{Binding Path=(hc:VisualElement.HighlightBackground),RelativeSource={RelativeSource TemplatedParent}}" TargetName="BorderRoot"/>
  37. <Setter Property="TextElement.Foreground" Value="{Binding Path=(hc:VisualElement.HighlightForeground),RelativeSource={RelativeSource TemplatedParent}}" TargetName="contentPresenter"/>
  38. </Trigger>
  39. <Trigger Property="Content" Value="{x:Null}">
  40. <Setter Property="Visibility" Value="Collapsed" TargetName="contentPresenter"/>
  41. </Trigger>
  42. <Trigger Property="hc:IconElement.Geometry" Value="{x:Null}">
  43. <Setter Property="Visibility" Value="Collapsed" TargetName="PathMain"/>
  44. <Setter Property="Margin" Value="0" TargetName="contentPresenter"/>
  45. </Trigger>
  46. </ControlTemplate.Triggers>
  47. </ControlTemplate>
  48. </Setter.Value>
  49. </Setter>
  50. <Style.Triggers>
  51. <Trigger Property="IsChecked" Value="True">
  52. <Setter Property="Panel.ZIndex" Value="{x:Static system:Int32.MaxValue}"/>
  53. </Trigger>
  54. <Trigger Property="IsMouseOver" Value="True">
  55. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  56. </Trigger>
  57. <Trigger Property="IsPressed" Value="True">
  58. <Setter Property="Background" Value="{DynamicResource BorderBrush}"/>
  59. </Trigger>
  60. </Style.Triggers>
  61. </Style>
  62. <Style TargetType="hc:Pagination">
  63. <Setter Property="hc:VisualElement.HighlightBorderBrush" Value="{DynamicResource TitleBrush}"/>
  64. <Setter Property="hc:VisualElement.HighlightBackground" Value="{DynamicResource TitleBrush}"/>
  65. <Setter Property="hc:VisualElement.HighlightForeground" Value="{DynamicResource TextIconBrush}"/>
  66. <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
  67. <Setter Property="PaginationButtonStyle" Value="{StaticResource PaginationButtonStyle}"/>
  68. <Setter Property="Focusable" Value="False"/>
  69. <Setter Property="UseLayoutRounding" Value="True"/>
  70. <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
  71. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  72. <Setter Property="Template">
  73. <Setter.Value>
  74. <ControlTemplate TargetType="hc:Pagination">
  75. <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
  76. <Button x:Name="PART_ButtonLeft" MinWidth="30" Padding="10,8" hc:IconElement.Geometry="{StaticResource LeftGeometry}" hc:BorderElement.CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='1,0,0,1'}" Command="interactivity:ControlCommands.Prev"/>
  77. <StackPanel ZIndex="999" HorizontalAlignment="Center" Orientation="Horizontal">
  78. <interactivity:Interaction.Triggers>
  79. <interactivity:RoutedEventTrigger RoutedEvent="RadioButton.Checked">
  80. <interactivity:EventToCommand Command="interactivity:ControlCommands.Selected" PassEventArgsToCommand="True" />
  81. </interactivity:RoutedEventTrigger>
  82. </interactivity:Interaction.Triggers>
  83. <RadioButton Name="PART_ButtonFirst" Content="1" IsChecked="True" Style="{TemplateBinding PaginationButtonStyle}"/>
  84. <Border Name="PART_MoreLeft" Cursor="No" Margin="-1,0,0,0" BorderThickness="1" BorderBrush="{TemplateBinding BorderBrush}" Background="{DynamicResource SecondaryRegionBrush}" Padding="10,0">
  85. <hc:SimpleText FontWeight="Bold" Foreground="{DynamicResource SecondaryTextBrush}" Text="..." VerticalAlignment="Center"/>
  86. </Border>
  87. <StackPanel Name="PART_PanelMain" Orientation="Horizontal"/>
  88. <Border Name="PART_MoreRight" Cursor="No" Margin="-1,0,0,0" BorderThickness="1" BorderBrush="{TemplateBinding BorderBrush}" Background="{DynamicResource SecondaryRegionBrush}" Padding="10,0">
  89. <hc:SimpleText FontWeight="Bold" Foreground="{DynamicResource SecondaryTextBrush}" Text="..." VerticalAlignment="Center"/>
  90. </Border>
  91. <RadioButton Name="PART_ButtonLast" Content="10" Style="{TemplateBinding PaginationButtonStyle}"/>
  92. </StackPanel>
  93. <Button x:Name="PART_ButtonRight" MinWidth="30" Padding="10,8" hc:IconElement.Geometry="{StaticResource RightGeometry}" hc:BorderElement.CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='0,1,1,0'}" Margin="-1,0,0,0" Command="interactivity:ControlCommands.Next"/>
  94. <hc:NumericUpDown x:Name="PART_Jump" IsEnabled="{TemplateBinding IsJumpEnabled}" Visibility="{TemplateBinding IsJumpEnabled,Converter={StaticResource Boolean2VisibilityConverter}}" Margin="6,0,0,0" Maximum="{Binding MaxPageCount,RelativeSource={RelativeSource TemplatedParent}}" Minimum="1"/>
  95. <Button IsEnabled="{TemplateBinding IsJumpEnabled}" Visibility="{TemplateBinding IsJumpEnabled,Converter={StaticResource Boolean2VisibilityConverter}}" Content="{ex:Lang {x:Static lang:LangKeys.Jump}}" Margin="6,0,0,0" Command="interactivity:ControlCommands.Jump"/>
  96. </StackPanel>
  97. </ControlTemplate>
  98. </Setter.Value>
  99. </Setter>
  100. </Style>
  101. </ResourceDictionary>