ImageSelectorBaseStyle.xaml 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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="ImageSelectorBaseStyle" TargetType="hc:ImageSelector">
  6. <Setter Property="Focusable" Value="False"/>
  7. <Setter Property="Stretch" Value="UniformToFill"/>
  8. <Setter Property="BorderThickness" Value="1"/>
  9. <Setter Property="StrokeThickness" Value="1"/>
  10. <Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
  11. <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
  12. <Setter Property="StrokeDashArray" Value="2,2"/>
  13. <Setter Property="hc:IconSwitchElement.Geometry" Value="{StaticResource AddGeometry}"/>
  14. <Setter Property="hc:IconSwitchElement.GeometrySelected" Value="{StaticResource RemoveGeometry}"/>
  15. <Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
  16. <Setter Property="Template">
  17. <Setter.Value>
  18. <ControlTemplate TargetType="hc:ImageSelector">
  19. <Button Command="interactivity:ControlCommands.Switch" Style="{StaticResource ButtonCustom}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
  20. <Border Background="{TemplateBinding Background}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}">
  21. <hc:DashedBorder BorderDashArray="{TemplateBinding StrokeDashArray}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" BorderDashThickness="{TemplateBinding StrokeThickness}" Background="{TemplateBinding PreviewBrush}" CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}">
  22. <Border Width="30" Height="30" Background="{TemplateBinding Background}" Style="{StaticResource BorderCircular}">
  23. <hc:ToggleBlock IsChecked="{TemplateBinding HasValue}">
  24. <hc:ToggleBlock.CheckedContent>
  25. <Path Data="{TemplateBinding hc:IconSwitchElement.GeometrySelected}" Width="12" Height="12" Fill="{DynamicResource PrimaryBrush}"/>
  26. </hc:ToggleBlock.CheckedContent>
  27. <hc:ToggleBlock.UnCheckedContent>
  28. <Path Data="{TemplateBinding hc:IconSwitchElement.Geometry}" Width="16" Height="16" Fill="{DynamicResource PrimaryBrush}"/>
  29. </hc:ToggleBlock.UnCheckedContent>
  30. </hc:ToggleBlock>
  31. </Border>
  32. </hc:DashedBorder>
  33. </Border>
  34. </Button>
  35. </ControlTemplate>
  36. </Setter.Value>
  37. </Setter>
  38. <Style.Triggers>
  39. <Trigger Property="IsMouseOver" Value="True">
  40. <Setter Property="Background" Value="{DynamicResource SecondaryRegionBrush}"/>
  41. <Setter Property="BorderBrush" Value="{DynamicResource PrimaryBrush}"/>
  42. </Trigger>
  43. </Style.Triggers>
  44. </Style>
  45. </ResourceDictionary>