PathButtonStyle.xaml 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:customControl="clr-namespace:PDF_Office.CustomControl">
  5. <Style TargetType="{x:Type customControl:PathButton}">
  6. <Setter Property="IconOpacity" Value="1" />
  7. <Setter Property="IconMouseOverOpacity" Value="1" />
  8. <Setter Property="IconPressOpacity" Value="1" />
  9. <Setter Property="IconCheckedOpacity" Value="1" />
  10. <Setter Property="IsChecked" Value="false" />
  11. <Setter Property="Background" Value="Transparent" />
  12. <Setter Property="Template">
  13. <Setter.Value>
  14. <ControlTemplate TargetType="{x:Type customControl:PathButton}">
  15. <Border
  16. Background="{TemplateBinding Background}"
  17. BorderBrush="{TemplateBinding BorderBrush}"
  18. BorderThickness="{TemplateBinding BorderThickness}">
  19. <Grid x:Name="grid" Background="{TemplateBinding Background}">
  20. <Border
  21. x:Name="PART_Border"
  22. Background="{TemplateBinding Background}"
  23. BorderBrush="{TemplateBinding BorderBrush}"
  24. BorderThickness="{TemplateBinding BorderThickness}"
  25. CornerRadius="{TemplateBinding CornerRadius}" />
  26. <Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
  27. <StackPanel
  28. Margin="{TemplateBinding Padding}"
  29. HorizontalAlignment="Center"
  30. VerticalAlignment="Center"
  31. Orientation="{TemplateBinding IconContentOrientation}">
  32. <Grid HorizontalAlignment="Center" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
  33. <Path
  34. x:Name="PART_Icon"
  35. Width="{TemplateBinding IconWidth}"
  36. Height="{TemplateBinding IconHeight}"
  37. Data="{TemplateBinding Icon}"
  38. Fill="{TemplateBinding IconFill}"
  39. Opacity="{TemplateBinding IconOpacity}" />
  40. <Path
  41. x:Name="PART_MouseOverIcon"
  42. Width="{TemplateBinding IconWidth}"
  43. Height="{TemplateBinding IconHeight}"
  44. Data="{TemplateBinding IconMouseOver}"
  45. Fill="{TemplateBinding IconMouseOverFill}"
  46. Opacity="{TemplateBinding IconMouseOverOpacity}"
  47. Visibility="Collapsed" />
  48. <Path
  49. x:Name="PART_PressIcon"
  50. Width="{TemplateBinding IconWidth}"
  51. Height="{TemplateBinding IconHeight}"
  52. Data="{TemplateBinding IconPress}"
  53. Fill="{TemplateBinding IconPressFill}"
  54. Opacity="{TemplateBinding IconPressOpacity}"
  55. Visibility="Collapsed" />
  56. <Path
  57. x:Name="PART_CheckedIcon"
  58. Width="{TemplateBinding IconWidth}"
  59. Height="{TemplateBinding IconHeight}"
  60. Data="{TemplateBinding IconChecked}"
  61. Fill="{TemplateBinding IconCheckedFill}"
  62. Opacity="{TemplateBinding IconCheckedOpacity}"
  63. Visibility="Collapsed" />
  64. </Grid>
  65. <TextBlock
  66. x:Name="PART_Content"
  67. Margin="{TemplateBinding IconContentMargin}"
  68. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  69. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  70. Foreground="{TemplateBinding Foreground}"
  71. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  72. Text="{TemplateBinding Content}"
  73. TextTrimming="CharacterEllipsis" />
  74. </StackPanel>
  75. </Grid>
  76. </Grid>
  77. </Border>
  78. <ControlTemplate.Triggers>
  79. <Trigger Property="IsMouseOver" Value="True">
  80. <Setter TargetName="PART_Content" Property="Foreground" Value="{Binding MouseOverForeground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:PathButton}}}" />
  81. <Setter TargetName="PART_Border" Property="Background" Value="{Binding MouseOverBackground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:PathButton}}}" />
  82. <Setter TargetName="PART_Border" Property="BorderBrush" Value="{Binding MouseOverBorderBrush, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:PathButton}}}" />
  83. <Setter TargetName="PART_MouseOverIcon" Property="Visibility" Value="Visible" />
  84. <Setter TargetName="PART_Icon" Property="Visibility" Value="Collapsed" />
  85. <Setter TargetName="PART_PressIcon" Property="Visibility" Value="Collapsed" />
  86. <Setter TargetName="PART_CheckedIcon" Property="Visibility" Value="Collapsed" />
  87. </Trigger>
  88. <Trigger Property="IsPressed" Value="True">
  89. <Setter TargetName="PART_Content" Property="Foreground" Value="{Binding MouseDownForeground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:PathButton}}}" />
  90. <Setter TargetName="PART_Border" Property="Background" Value="{Binding MouseDownBackground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:PathButton}}}" />
  91. <Setter TargetName="PART_Border" Property="BorderBrush" Value="{Binding MouseDownBorderBrush, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:PathButton}}}" />
  92. <Setter TargetName="PART_PressIcon" Property="Visibility" Value="Visible" />
  93. <Setter TargetName="PART_Icon" Property="Visibility" Value="Collapsed" />
  94. <Setter TargetName="PART_MouseOverIcon" Property="Visibility" Value="Collapsed" />
  95. <Setter TargetName="PART_CheckedIcon" Property="Visibility" Value="Collapsed" />
  96. </Trigger>
  97. <Trigger Property="IsEnabled" Value="False">
  98. <Setter Property="Opacity" Value="0.5" />
  99. </Trigger>
  100. <Trigger Property="IsChecked" Value="True">
  101. <Setter TargetName="PART_Content" Property="Foreground" Value="{Binding MouseOverForeground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:PathButton}}}" />
  102. <Setter TargetName="PART_Border" Property="Background" Value="{Binding MouseOverBackground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:PathButton}}}" />
  103. <Setter TargetName="PART_Border" Property="BorderBrush" Value="{Binding MouseOverBorderBrush, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:PathButton}}}" />
  104. <Setter TargetName="PART_MouseOverIcon" Property="Visibility" Value="Collapsed" />
  105. <Setter TargetName="PART_Icon" Property="Visibility" Value="Collapsed" />
  106. <Setter TargetName="PART_PressIcon" Property="Visibility" Value="Collapsed" />
  107. <Setter TargetName="PART_CheckedIcon" Property="Visibility" Value="Visible" />
  108. </Trigger>
  109. <Trigger SourceName="PART_Content" Property="Text" Value="">
  110. <Setter TargetName="PART_Content" Property="Visibility" Value="Collapsed" />
  111. </Trigger>
  112. <Trigger SourceName="PART_Content" Property="Text" Value="{x:Null}">
  113. <Setter TargetName="PART_Content" Property="Visibility" Value="Collapsed" />
  114. </Trigger>
  115. </ControlTemplate.Triggers>
  116. </ControlTemplate>
  117. </Setter.Value>
  118. </Setter>
  119. </Style>
  120. </ResourceDictionary>