ImageRadioButtonDictionary.xaml 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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_Master.CustomControl">
  5. <Style TargetType="{x:Type customControl:ImageRadioButton}">
  6. <Setter Property="Background" Value="Transparent" />
  7. <Setter Property="Template">
  8. <Setter.Value>
  9. <ControlTemplate TargetType="{x:Type customControl:ImageRadioButton}">
  10. <Border
  11. Background="{TemplateBinding Background}"
  12. BorderBrush="{TemplateBinding BorderBrush}"
  13. BorderThickness="{TemplateBinding BorderThickness}">
  14. <Grid x:Name="grid" Background="{TemplateBinding Background}">
  15. <Border
  16. x:Name="PART_Border"
  17. Background="{TemplateBinding Background}"
  18. BorderBrush="{TemplateBinding BorderBrush}"
  19. BorderThickness="{TemplateBinding BorderThickness}"
  20. CornerRadius="{TemplateBinding CornerRadius}" />
  21. <Grid HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
  22. <StackPanel
  23. Margin="{TemplateBinding Padding}"
  24. HorizontalAlignment="Center"
  25. VerticalAlignment="Center"
  26. Orientation="{TemplateBinding IconContentOrientation}">
  27. <Grid HorizontalAlignment="Center" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
  28. <Image
  29. x:Name="PART_Icon"
  30. Width="{TemplateBinding IconWidth}"
  31. Height="{TemplateBinding IconHeight}"
  32. Source="{TemplateBinding Icon}" />
  33. <Image
  34. x:Name="PART_MouseOverIcon"
  35. Width="{TemplateBinding IconWidth}"
  36. Height="{TemplateBinding IconHeight}"
  37. Source="{TemplateBinding IconMouseOver}"
  38. Visibility="Collapsed" />
  39. <Image
  40. x:Name="PART_PressIcon"
  41. Width="{TemplateBinding IconWidth}"
  42. Height="{TemplateBinding IconHeight}"
  43. Source="{TemplateBinding IconPress}"
  44. Visibility="Collapsed" />
  45. <Image
  46. x:Name="PART_CheckedIcon"
  47. Width="{TemplateBinding IconWidth}"
  48. Height="{TemplateBinding IconHeight}"
  49. Source="{TemplateBinding IconChecked}"
  50. Visibility="Collapsed" />
  51. </Grid>
  52. <TextBlock
  53. x:Name="PART_Content"
  54. Margin="{TemplateBinding IconContentMargin}"
  55. HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  56. VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
  57. Foreground="{TemplateBinding Foreground}"
  58. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  59. Text="{TemplateBinding Content}"
  60. TextTrimming="CharacterEllipsis" />
  61. </StackPanel>
  62. </Grid>
  63. </Grid>
  64. </Border>
  65. <ControlTemplate.Triggers>
  66. <Trigger Property="IsMouseOver" Value="True">
  67. <Setter TargetName="PART_Content" Property="Foreground" Value="{Binding MouseOverForeground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:ImageRadioButton}}}" />
  68. <Setter TargetName="PART_Border" Property="Background" Value="{Binding MouseOverBackground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:ImageRadioButton}}}" />
  69. <Setter TargetName="PART_Border" Property="BorderBrush" Value="{Binding MouseOverBorderBrush, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:ImageRadioButton}}}" />
  70. <Setter TargetName="PART_MouseOverIcon" Property="Visibility" Value="Visible" />
  71. <Setter TargetName="PART_Icon" Property="Visibility" Value="Collapsed" />
  72. <Setter TargetName="PART_PressIcon" Property="Visibility" Value="Collapsed" />
  73. <Setter TargetName="PART_CheckedIcon" Property="Visibility" Value="Collapsed" />
  74. </Trigger>
  75. <Trigger Property="IsPressed" Value="True">
  76. <Setter TargetName="PART_Content" Property="Foreground" Value="{Binding MouseDownForeground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:ImageRadioButton}}}" />
  77. <Setter TargetName="PART_Border" Property="Background" Value="{Binding MouseDownBackground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:ImageRadioButton}}}" />
  78. <Setter TargetName="PART_Border" Property="BorderBrush" Value="{Binding MouseDownBorderBrush, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:ImageRadioButton}}}" />
  79. <Setter TargetName="PART_PressIcon" Property="Visibility" Value="Visible" />
  80. <Setter TargetName="PART_Icon" Property="Visibility" Value="Collapsed" />
  81. <Setter TargetName="PART_MouseOverIcon" Property="Visibility" Value="Collapsed" />
  82. <Setter TargetName="PART_CheckedIcon" Property="Visibility" Value="Collapsed" />
  83. </Trigger>
  84. <Trigger Property="IsEnabled" Value="False">
  85. <Setter Property="Opacity" Value="0.5" />
  86. </Trigger>
  87. <Trigger Property="IsChecked" Value="True">
  88. <Setter TargetName="PART_Content" Property="Foreground" Value="{Binding MouseOverForeground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:ImageRadioButton}}}" />
  89. <Setter TargetName="PART_Border" Property="Background" Value="{Binding MouseOverBackground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:ImageRadioButton}}}" />
  90. <Setter TargetName="PART_Border" Property="BorderBrush" Value="{Binding MouseOverBorderBrush, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type customControl:ImageRadioButton}}}" />
  91. <Setter TargetName="PART_MouseOverIcon" Property="Visibility" Value="Collapsed" />
  92. <Setter TargetName="PART_Icon" Property="Visibility" Value="Collapsed" />
  93. <Setter TargetName="PART_PressIcon" Property="Visibility" Value="Collapsed" />
  94. <Setter TargetName="PART_CheckedIcon" Property="Visibility" Value="Visible" />
  95. </Trigger>
  96. <Trigger SourceName="PART_Content" Property="Text" Value="">
  97. <Setter TargetName="PART_Content" Property="Visibility" Value="Collapsed" />
  98. </Trigger>
  99. <Trigger SourceName="PART_Content" Property="Text" Value="{x:Null}">
  100. <Setter TargetName="PART_Content" Property="Visibility" Value="Collapsed" />
  101. </Trigger>
  102. </ControlTemplate.Triggers>
  103. </ControlTemplate>
  104. </Setter.Value>
  105. </Setter>
  106. </Style>
  107. </ResourceDictionary>