RadioButton.xaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <ResourceDictionary
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:ctrl="http://OpenSEMI.Ctrlib.com/presentation"
  7. xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
  8. mc:Ignorable="d">
  9. <SolidColorBrush x:Key="RadioButton_BG" Color="#FF3d8d73"/>
  10. <LinearGradientBrush x:Key="RadioButton_BG_Color" EndPoint="0,0" StartPoint="0,1">
  11. <GradientStop Color="White" Offset="0"/>
  12. <GradientStop Color="White" Offset="0.9"/>
  13. <GradientStop Color="#FFD0D0D0" Offset="1"/>
  14. </LinearGradientBrush>
  15. <SolidColorBrush x:Key="RadioButton_BD" Color="#FF107268"/>
  16. <SolidColorBrush x:Key="RadioButton_BD_Shadow" Color="#FF284775"/>
  17. <SolidColorBrush x:Key="RadioButton_BG_MouseOver" Color="#FF4FCBFF"/>
  18. <SolidColorBrush x:Key="RadioButton_BG_Press" Color="#FF5A89D4"/>
  19. <SolidColorBrush x:Key="RadioButton_BG_Unable" Color="#FFD2D2D2"/>
  20. <SolidColorBrush x:Key="RadioButton_BD_Unable" Color="#FFF3F3F3"/>
  21. <SolidColorBrush x:Key="RadioButton_BD_Shadow_Unable" Color="#FF9D9D9D"/>
  22. <SolidColorBrush x:Key="RadioButton_BG_Checked" Color="#FFb8fff8"/>
  23. <SolidColorBrush x:Key="RadioButton_BD_Checked" Color="#FFF3F3F3"/>
  24. <SolidColorBrush x:Key="RadioButton_BD_Shadow_Checked" Color="#FF9D9D9D"/>
  25. <SolidColorBrush x:Key="TopFrame_BG" Color="#FFD1E3CF"/>
  26. <!-- Normal Button style -->
  27. <Style TargetType="{x:Type RadioButton}" x:Key="NormalRadioButtonStyle">
  28. <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
  29. <Setter Property="Background" Value="{StaticResource TopFrame_BG}"/>
  30. <Setter Property="BorderBrush" Value="Black"/>
  31. <Setter Property="BorderThickness" Value="2,2,0,0"/>
  32. <Setter Property="Foreground" Value="{DynamicResource FG_Black}"/>
  33. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  34. <Setter Property="VerticalContentAlignment" Value="Center"/>
  35. <Setter Property="Padding" Value="6,3"/>
  36. <Setter Property="MinWidth" Value="40"/>
  37. <Setter Property="MinHeight" Value="20"/>
  38. <Setter Property="SnapsToDevicePixels" Value="True"/>
  39. <Setter Property="Border.CornerRadius" Value="4"/>
  40. <Setter Property="Template">
  41. <Setter.Value>
  42. <ControlTemplate TargetType="{x:Type RadioButton}">
  43. <Border x:Name="BG" BorderThickness="{TemplateBinding BorderThickness}"
  44. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  45. CornerRadius="{TemplateBinding Border.CornerRadius}"
  46. BorderBrush="{TemplateBinding BorderBrush}"
  47. Background="{TemplateBinding Background}" Cursor="Hand">
  48. <Border x:Name="Inner_BD"
  49. BorderBrush="WhiteSmoke"
  50. BorderThickness="0,0,2,2" Margin="0,0,-2,-2" CornerRadius="3" Padding="5,1">
  51. <ContentPresenter x:Name="contentpresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
  52. Margin="{TemplateBinding Padding}" RecognizesAccessKey="True"
  53. SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
  54. VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Cursor="Hand">
  55. </ContentPresenter>
  56. </Border>
  57. </Border>
  58. <ControlTemplate.Triggers>
  59. <Trigger Property="IsMouseOver" Value="True">
  60. <Setter TargetName="BG" Property="Background" Value="{StaticResource RadioButton_BG_MouseOver}"/>
  61. </Trigger>
  62. <Trigger Property="IsPressed" Value="True">
  63. <Setter TargetName="BG" Property="Background" Value="{StaticResource RadioButton_BG_Press}"/>
  64. <Setter TargetName="BG" Property="Margin" Value="1"/>
  65. <Setter Property="FontSize" Value="13"/>
  66. </Trigger>
  67. <Trigger Property="IsEnabled" Value="False">
  68. <Setter TargetName="BG" Property="Background" Value="{StaticResource RadioButton_BG_Unable}"/>
  69. <Setter TargetName="BG" Property="BorderBrush" Value="{StaticResource RadioButton_BD_Unable}"/>
  70. <Setter TargetName="Inner_BD" Property="BorderBrush" Value="{StaticResource RadioButton_BD_Shadow_Unable}"/>
  71. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  72. </Trigger>
  73. <Trigger Property="IsChecked" Value="True">
  74. <Setter TargetName="BG" Property="Background" Value="{StaticResource TopFrame_BG}"/>
  75. <Setter Property="FontSize" Value="16"/>
  76. <Setter Property="FontWeight" Value="Bold"/>
  77. <Setter TargetName="BG" Property="BorderBrush" Value="{StaticResource RadioButton_BD}"/>
  78. <Setter TargetName="Inner_BD" Property="BorderBrush" Value="{StaticResource RadioButton_BD_Unable}"/>
  79. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  80. </Trigger>
  81. <Trigger Property="IsChecked" Value="False">
  82. <Setter TargetName="BG" Property="BorderBrush" Value="White"/>
  83. <Setter Property="FontSize" Value="13"/>
  84. <Setter Property="FontWeight" Value="Normal"/>
  85. <Setter TargetName="Inner_BD" Property="BorderBrush" Value="{StaticResource RadioButton_BD}"/>
  86. <Setter Property="TextBlock.Foreground" TargetName="contentpresenter" Value="WhiteSmoke"/>
  87. </Trigger>
  88. </ControlTemplate.Triggers>
  89. </ControlTemplate>
  90. </Setter.Value>
  91. </Setter>
  92. </Style>
  93. <Style TargetType="RadioButton" BasedOn="{StaticResource NormalRadioButtonStyle}"/>
  94. <Style x:Key="DemoStyle" TargetType="{x:Type RadioButton}">
  95. <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
  96. <Setter Property="Background" Value="{StaticResource RadioButton_BG_Color}"/>
  97. <Setter Property="BorderBrush" Value="{StaticResource RadioButton_BD}"/>
  98. <Setter Property="BorderThickness" Value="1,1,0,0"/>
  99. <Setter Property="FontFamily" Value="Arial"/>
  100. <Setter Property="FontSize" Value="14"/>
  101. <Setter Property="Foreground" Value="{DynamicResource FG_Black}"/>
  102. <Setter Property="HorizontalContentAlignment" Value="Left"/>
  103. <Setter Property="VerticalContentAlignment" Value="Center"/>
  104. <Setter Property="Padding" Value="6,3"/>
  105. <Setter Property="MinWidth" Value="40"/>
  106. <Setter Property="MinHeight" Value="20"/>
  107. <Setter Property="SnapsToDevicePixels" Value="True"/>
  108. <Setter Property="Border.CornerRadius" Value="4"/>
  109. <Setter Property="Template">
  110. <Setter.Value>
  111. <ControlTemplate TargetType="{x:Type RadioButton}">
  112. <Border x:Name="BG" BorderThickness="{TemplateBinding BorderThickness}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" CornerRadius="{TemplateBinding Border.CornerRadius}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Cursor="Hand">
  113. <Border x:Name="Inner_BD" BorderBrush="{StaticResource RadioButton_BD_Shadow}" BorderThickness="0,0,1,1" CornerRadius="3" Padding="5,1">
  114. <ContentPresenter x:Name="contentpresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Cursor="Hand">
  115. </ContentPresenter>
  116. </Border>
  117. </Border>
  118. <ControlTemplate.Triggers>
  119. <Trigger Property="IsMouseOver" Value="True">
  120. <Setter TargetName="BG" Property="Background" Value="{StaticResource RadioButton_BG_MouseOver}"/>
  121. </Trigger>
  122. <Trigger Property="IsPressed" Value="True">
  123. <Setter TargetName="BG" Property="Background" Value="{StaticResource RadioButton_BG_Press}"/>
  124. <Setter TargetName="BG" Property="Margin" Value="1"/>
  125. <Setter Property="FontSize" Value="13"/>
  126. </Trigger>
  127. <Trigger Property="IsEnabled" Value="False">
  128. <Setter TargetName="BG" Property="Background" Value="{StaticResource RadioButton_BG_Unable}"/>
  129. <Setter TargetName="BG" Property="BorderBrush" Value="{StaticResource RadioButton_BD_Unable}"/>
  130. <Setter TargetName="Inner_BD" Property="BorderBrush" Value="{StaticResource RadioButton_BD_Shadow_Unable}"/>
  131. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  132. </Trigger>
  133. <Trigger Property="IsChecked" Value="True">
  134. <Setter TargetName="BG" Property="Background" Value="{StaticResource RadioButton_BG_Checked}"/>
  135. <Setter TargetName="BG" Property="BorderBrush" Value="{StaticResource RadioButton_BD_Checked}"/>
  136. <Setter TargetName="Inner_BD" Property="BorderBrush" Value="{StaticResource RadioButton_BD_Shadow_Checked}"/>
  137. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  138. </Trigger>
  139. <Trigger Property="IsChecked" Value="False">
  140. <Setter TargetName="BG" Property="Background" Value="{StaticResource RadioButton_BG_Color}"/>
  141. <Setter TargetName="BG" Property="BorderBrush" Value="{StaticResource RadioButton_BD}"/>
  142. <Setter TargetName="Inner_BD" Property="BorderBrush" Value="{StaticResource RadioButton_BD_Shadow_Checked}"/>
  143. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
  144. </Trigger>
  145. </ControlTemplate.Triggers>
  146. </ControlTemplate>
  147. </Setter.Value>
  148. </Setter>
  149. </Style>
  150. </ResourceDictionary>