Carousel.xaml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. <Style x:Key="CarouselItemBaseStyle" TargetType="hc:CarouselItem">
  6. <Setter Property="Focusable" Value="False"/>
  7. <Setter Property="Template">
  8. <Setter.Value>
  9. <ControlTemplate TargetType="hc:CarouselItem">
  10. <Border BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}">
  11. <ContentPresenter Margin="{TemplateBinding Padding}" ContentTemplate="{Binding ItemTemplate,RelativeSource={RelativeSource AncestorType=hc:Carousel}}"/>
  12. </Border>
  13. </ControlTemplate>
  14. </Setter.Value>
  15. </Setter>
  16. </Style>
  17. <Style x:Key="CarouselPateButton" BasedOn="{StaticResource BaseStyle}" TargetType="RadioButton">
  18. <Setter Property="Margin" Value="5,0"/>
  19. <Setter Property="Width" Value="10"/>
  20. <Setter Property="Height" Value="10"/>
  21. <Setter Property="Background" Value="White"/>
  22. <Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
  23. <Setter Property="Padding" Value="0"/>
  24. <Setter Property="BorderThickness" Value="1"/>
  25. <Setter Property="Template">
  26. <Setter.Value>
  27. <ControlTemplate TargetType="ToggleButton">
  28. <Border CornerRadius="5" SnapsToDevicePixels="true" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}"/>
  29. <ControlTemplate.Triggers>
  30. <Trigger Property="IsMouseOver" Value="True">
  31. <Setter Property="Opacity" Value=".9"/>
  32. </Trigger>
  33. <Trigger Property="IsPressed" Value="True">
  34. <Setter Property="Opacity" Value=".6"/>
  35. </Trigger>
  36. <Trigger Property="IsChecked" Value="True">
  37. <Setter Property="Background" Value="{DynamicResource PrimaryBrush}"/>
  38. </Trigger>
  39. </ControlTemplate.Triggers>
  40. </ControlTemplate>
  41. </Setter.Value>
  42. </Setter>
  43. </Style>
  44. <Style TargetType="hc:Carousel">
  45. <Setter Property="PageButtonStyle" Value="{StaticResource CarouselPateButton}"/>
  46. <Setter Property="ItemContainerStyle" Value="{StaticResource CarouselItemBaseStyle}"/>
  47. <Setter Property="Template">
  48. <Setter.Value>
  49. <ControlTemplate TargetType="hc:Carousel">
  50. <ControlTemplate.Triggers>
  51. <EventTrigger RoutedEvent="FrameworkElement.MouseEnter">
  52. <BeginStoryboard>
  53. <Storyboard>
  54. <DoubleAnimation Storyboard.TargetName="GridTop" Storyboard.TargetProperty="Opacity" To="1" Duration="0:0:.1"/>
  55. </Storyboard>
  56. </BeginStoryboard>
  57. </EventTrigger>
  58. <EventTrigger RoutedEvent="FrameworkElement.MouseLeave">
  59. <BeginStoryboard>
  60. <Storyboard>
  61. <DoubleAnimation Storyboard.TargetName="GridTop" Storyboard.TargetProperty="Opacity" To="0" Duration="0:0:.1"/>
  62. </Storyboard>
  63. </BeginStoryboard>
  64. </EventTrigger>
  65. </ControlTemplate.Triggers>
  66. <hc:SimplePanel ClipToBounds="True">
  67. <StackPanel x:Name="PART_Panel" Orientation="Horizontal"/>
  68. <hc:SimplePanel x:Name="GridTop" Opacity="0">
  69. <Button Command="interactivity:ControlCommands.Prev" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="30,0,0,0" Style="{StaticResource ButtonCustom}">
  70. <Border Width="50" Height="100" Background="{DynamicResource DarkOpacityBrush}" CornerRadius="4">
  71. <Path Margin="16" Fill="White" Style="{StaticResource LeftPathStyle}"/>
  72. </Border>
  73. </Button>
  74. <Button Command="interactivity:ControlCommands.Next" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="0,0,30,0" Style="{StaticResource ButtonCustom}">
  75. <Border Width="50" Height="100" Background="{DynamicResource DarkOpacityBrush}" CornerRadius="4">
  76. <Path Margin="16" Fill="White" Style="{StaticResource RightPathStyle}"/>
  77. </Border>
  78. </Button>
  79. </hc:SimplePanel>
  80. <StackPanel Name="PART_PanelPage" Orientation="Horizontal" VerticalAlignment="Bottom" HorizontalAlignment="Center" Margin="0,0,0,20"/>
  81. </hc:SimplePanel>
  82. </ControlTemplate>
  83. </Setter.Value>
  84. </Setter>
  85. </Style>
  86. </ResourceDictionary>