RadioButtonStyle.xaml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:local="clr-namespace:ComPDFKit.Controls.Asset.Styles">
  4. <Style x:Key="TCIRadioButtonStyle" TargetType="RadioButton">
  5. <Setter Property="Background" Value="Red"></Setter>
  6. <Setter Property="Template">
  7. <Setter.Value>
  8. <ControlTemplate TargetType="{x:Type local:TCIRadioButton}">
  9. <Grid HorizontalAlignment="Left">
  10. <Grid.ColumnDefinitions>
  11. <ColumnDefinition Width="40"></ColumnDefinition>
  12. <ColumnDefinition Width="auto"></ColumnDefinition>
  13. </Grid.ColumnDefinitions>
  14. <Grid Grid.RowSpan="2">
  15. <Ellipse x:Name="RadioEllipse"
  16. Width="20"
  17. Height="20"
  18. Fill="White"
  19. Stroke="{TemplateBinding BorderBrush}"
  20. StrokeThickness="1"/>
  21. <Ellipse x:Name="InnerEllipse"
  22. Width="15"
  23. Height="15"
  24. Fill="Black"
  25. Opacity="0"/>
  26. </Grid>
  27. <Border x:Name="Border" BorderBrush="#1A000000" BorderThickness="1" Grid.Column="1" CornerRadius="1" Padding="10" HorizontalAlignment="Stretch" Background="Transparent">
  28. <Grid>
  29. <Grid.ColumnDefinitions>
  30. <ColumnDefinition></ColumnDefinition>
  31. <ColumnDefinition></ColumnDefinition>
  32. </Grid.ColumnDefinitions>
  33. <!-- 这里是 ContentPresenter -->
  34. <Grid x:Name="PART_IconGrid" Width="32" Margin="0,0,10,0">
  35. <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
  36. </Grid>
  37. <Grid Name="TextGd" Grid.Column="1" Width="{TemplateBinding TextWidth}" VerticalAlignment="Center">
  38. <Grid.RowDefinitions>
  39. <RowDefinition Height="25"></RowDefinition>
  40. <RowDefinition></RowDefinition>
  41. </Grid.RowDefinitions>
  42. <TextBlock Text="{TemplateBinding Title}" TextWrapping="Wrap" FontSize="14" FontWeight="Bold" FontFamily="Microsoft YaHei"></TextBlock>
  43. <TextBlock Grid.Row="1" Text="{TemplateBinding Description}" TextWrapping="Wrap" FontSize="12" FontWeight="Normal" FontFamily="Microsoft YaHei"></TextBlock>
  44. </Grid>
  45. </Grid>
  46. </Border>
  47. </Grid>
  48. <ControlTemplate.Triggers>
  49. <Trigger Property="IsChecked" Value="True">
  50. <Setter TargetName="InnerEllipse" Property="Opacity" Value="1"/>
  51. </Trigger>
  52. <Trigger Property="IsMouseOver" Value="True">
  53. <Setter TargetName="RadioEllipse" Property="Stroke" Value="DodgerBlue"/>
  54. <Setter TargetName="InnerEllipse" Property="Stroke" Value="DodgerBlue"/>
  55. <Setter TargetName="Border" Property="Background" Value="AliceBlue"></Setter>
  56. </Trigger>
  57. </ControlTemplate.Triggers>
  58. </ControlTemplate>
  59. </Setter.Value>
  60. </Setter>
  61. </Style>
  62. <Style x:Key="{x:Type RadioButton}" TargetType="{x:Type RadioButton}">
  63. <Setter Property="Template">
  64. <Setter.Value>
  65. <ControlTemplate TargetType="{x:Type RadioButton}">
  66. <Grid HorizontalAlignment="Left">
  67. <Grid.ColumnDefinitions>
  68. <ColumnDefinition Width="32"></ColumnDefinition>
  69. <ColumnDefinition></ColumnDefinition>
  70. </Grid.ColumnDefinitions>
  71. <Grid>
  72. <Ellipse x:Name="radioEllipse"
  73. Width="16"
  74. Height="16"
  75. Fill="White"
  76. Stroke="{TemplateBinding BorderBrush}"
  77. StrokeThickness="1"/>
  78. <Ellipse x:Name="innerEllipse"
  79. Width="11"
  80. Height="11"
  81. Fill="Black"
  82. Opacity="0"/>
  83. </Grid>
  84. <Grid x:Name="textGd" Grid.Column="1" VerticalAlignment="Center">
  85. <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
  86. <ContentPresenter.Style>
  87. <Style TargetType="ContentPresenter">
  88. <Style.Triggers>
  89. <DataTrigger Binding="{Binding IsEnabled, RelativeSource={RelativeSource TemplatedParent}}" Value="False">
  90. <Setter Property="Opacity" Value="0.5"/>
  91. </DataTrigger>
  92. </Style.Triggers>
  93. </Style>
  94. </ContentPresenter.Style>
  95. </ContentPresenter>
  96. </Grid>
  97. </Grid>
  98. <ControlTemplate.Triggers>
  99. <Trigger Property="IsChecked" Value="True">
  100. <Setter TargetName="innerEllipse" Property="Opacity" Value="1"></Setter>
  101. </Trigger>
  102. <Trigger Property="IsMouseOver" Value="True">
  103. <Setter TargetName="radioEllipse" Property="Stroke" Value="DodgerBlue"></Setter>
  104. </Trigger>
  105. <Trigger Property="IsEnabled" Value="False">
  106. <Setter TargetName="radioEllipse" Property="Fill" Value="#1A000000"></Setter>
  107. <Setter TargetName="radioEllipse" Property="Stroke" Value="#5A000000"></Setter>
  108. <Setter TargetName="innerEllipse" Property="Fill" Value="#1A000000"></Setter>
  109. </Trigger>
  110. </ControlTemplate.Triggers>
  111. </ControlTemplate>
  112. </Setter.Value>
  113. </Setter>
  114. </Style>
  115. <Style x:Key="MatrixRadioButton" TargetType="{x:Type RadioButton}">
  116. <Setter Property="Template">
  117. <Setter.Value>
  118. <ControlTemplate TargetType="{x:Type RadioButton}">
  119. <Grid>
  120. <Grid>
  121. <Rectangle x:Name="radioRectangle"
  122. Width="28"
  123. Height="28"
  124. Fill="#DDE9FF"/>
  125. </Grid>
  126. <Grid x:Name="textGd" Grid.Column="1" VerticalAlignment="Center">
  127. <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
  128. <ContentPresenter.Style>
  129. <Style TargetType="ContentPresenter">
  130. <Style.Triggers>
  131. <DataTrigger Binding="{Binding IsEnabled, RelativeSource={RelativeSource TemplatedParent}}" Value="False">
  132. <Setter Property="Opacity" Value="0.5"/>
  133. </DataTrigger>
  134. </Style.Triggers>
  135. </Style>
  136. </ContentPresenter.Style>
  137. </ContentPresenter>
  138. </Grid>
  139. </Grid>
  140. <ControlTemplate.Triggers>
  141. <Trigger Property="IsChecked" Value="True">
  142. <Setter TargetName="radioRectangle" Property="Fill" Value="#4982E6"></Setter>
  143. </Trigger>
  144. <Trigger Property="IsMouseOver" Value="True">
  145. <Setter TargetName="radioRectangle" Property="Fill" Value="#93B6F3"></Setter>
  146. </Trigger>
  147. <Trigger Property="IsPressed" Value="True">
  148. <Setter TargetName="radioRectangle" Property="Fill" Value="#3953A4"></Setter>
  149. </Trigger>
  150. </ControlTemplate.Triggers>
  151. </ControlTemplate>
  152. </Setter.Value>
  153. </Setter>
  154. </Style>
  155. </ResourceDictionary>