回答編集履歴

2

見直しキャンペーン中

2023/07/28 13:50

投稿

TN8001
TN8001

スコア9862

test CHANGED
@@ -1,201 +1,101 @@
1
1
  これで解決するかは不明ですが、Windows 10 & Visual Studio 2019で出したStyleを提示しておきます。
2
2
 
3
-
4
-
5
3
  ![Style出力](014bc18a4e93d9dca8390ddf8e2cc498.png)
6
-
7
- ```xaml
4
+ ```xml
8
-
9
5
  <Window
10
-
11
6
  x:Class="Questions349003.MainWindow"
12
-
13
7
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
14
-
15
8
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
16
-
17
9
  Width="800"
18
-
19
10
  Height="450">
20
-
21
11
  <Window.Resources>
22
-
23
12
  <Style x:Key="FocusVisual">
24
-
25
13
  <Setter Property="Control.Template">
26
-
27
14
  <Setter.Value>
28
-
29
15
  <ControlTemplate>
30
-
31
16
  <Rectangle Margin="2" StrokeDashArray="1 2" SnapsToDevicePixels="true" StrokeThickness="1" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
32
-
33
17
  </ControlTemplate>
34
-
35
18
  </Setter.Value>
36
-
37
19
  </Setter>
38
-
39
20
  </Style>
40
-
41
21
  <Style x:Key="OptionMarkFocusVisual">
42
-
43
22
  <Setter Property="Control.Template">
44
-
45
23
  <Setter.Value>
46
-
47
24
  <ControlTemplate>
48
-
49
25
  <Rectangle Margin="14,0,0,0" StrokeDashArray="1 2" SnapsToDevicePixels="true" StrokeThickness="1" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
50
-
51
26
  </ControlTemplate>
52
-
53
27
  </Setter.Value>
54
-
55
28
  </Setter>
56
-
57
29
  </Style>
58
-
59
30
  <SolidColorBrush x:Key="RadioButton.Static.Background" Color="#FFFFFFFF"/>
60
-
61
31
  <SolidColorBrush x:Key="RadioButton.Static.Border" Color="#FF707070"/>
62
-
63
32
  <SolidColorBrush x:Key="RadioButton.Static.Glyph" Color="#FF212121"/>
64
-
65
33
  <SolidColorBrush x:Key="RadioButton.MouseOver.Background" Color="#FFF3F9FF"/>
66
-
67
34
  <SolidColorBrush x:Key="RadioButton.MouseOver.Border" Color="#FF5593FF"/>
68
-
69
35
  <SolidColorBrush x:Key="RadioButton.MouseOver.Glyph" Color="#FF212121"/>
70
-
71
36
  <SolidColorBrush x:Key="RadioButton.Pressed.Background" Color="#FFD9ECFF"/>
72
-
73
37
  <SolidColorBrush x:Key="RadioButton.Pressed.Border" Color="#FF3C77DD"/>
74
-
75
38
  <SolidColorBrush x:Key="RadioButton.Pressed.Glyph" Color="#FF212121"/>
76
-
77
39
  <SolidColorBrush x:Key="RadioButton.Disabled.Background" Color="#FFE6E6E6"/>
78
-
79
40
  <SolidColorBrush x:Key="RadioButton.Disabled.Border" Color="#FFBCBCBC"/>
80
-
81
41
  <SolidColorBrush x:Key="RadioButton.Disabled.Glyph" Color="#FF707070"/>
82
-
83
42
  <Style TargetType="{x:Type RadioButton}">
84
-
85
43
  <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisual}"/>
86
-
87
44
  <Setter Property="Background" Value="{StaticResource RadioButton.Static.Background}"/>
88
-
89
45
  <Setter Property="BorderBrush" Value="{StaticResource RadioButton.Static.Border}"/>
90
-
91
46
  <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
92
-
93
47
  <Setter Property="BorderThickness" Value="1"/>
94
-
95
48
  <Setter Property="Template">
96
-
97
49
  <Setter.Value>
98
-
99
50
  <ControlTemplate TargetType="{x:Type RadioButton}">
100
-
101
51
  <Grid x:Name="templateRoot" Background="Transparent" SnapsToDevicePixels="True">
102
-
103
52
  <Grid.ColumnDefinitions>
104
-
105
53
  <ColumnDefinition Width="Auto"/>
106
-
107
54
  <ColumnDefinition Width="*"/>
108
-
109
55
  </Grid.ColumnDefinitions>
110
-
111
56
  <Border x:Name="radioButtonBorder" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="100" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="1,1,2,1" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
112
-
113
57
  <Grid x:Name="markGrid" Margin="2">
114
-
115
58
  <Ellipse x:Name="optionMark" Fill="{StaticResource RadioButton.Static.Glyph}" MinHeight="6" MinWidth="6" Opacity="0"/>
116
-
117
59
  </Grid>
118
-
119
60
  </Border>
120
-
121
61
  <ContentPresenter x:Name="contentPresenter" Grid.Column="1" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
122
-
123
62
  </Grid>
124
-
125
63
  <ControlTemplate.Triggers>
126
-
127
64
  <Trigger Property="HasContent" Value="true">
128
-
129
65
  <Setter Property="FocusVisualStyle" Value="{StaticResource OptionMarkFocusVisual}"/>
130
-
131
66
  <Setter Property="Padding" Value="4,-1,0,0"/>
132
-
133
67
  </Trigger>
134
-
135
68
  <Trigger Property="IsMouseOver" Value="true">
136
-
137
69
  <Setter Property="Background" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.MouseOver.Background}"/>
138
-
139
70
  <Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.MouseOver.Border}"/>
140
-
141
71
  <Setter Property="Fill" TargetName="optionMark" Value="{StaticResource RadioButton.MouseOver.Glyph}"/>
142
-
143
72
  </Trigger>
144
-
145
73
  <Trigger Property="IsEnabled" Value="false">
146
-
147
74
  <Setter Property="Background" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.Disabled.Background}"/>
148
-
149
75
  <Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.Disabled.Border}"/>
150
-
151
76
  <Setter Property="Fill" TargetName="optionMark" Value="{StaticResource RadioButton.Disabled.Glyph}"/>
152
-
153
77
  </Trigger>
154
-
155
78
  <Trigger Property="IsPressed" Value="true">
156
-
157
79
  <Setter Property="Background" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.Pressed.Background}"/>
158
-
159
80
  <Setter Property="BorderBrush" TargetName="radioButtonBorder" Value="{StaticResource RadioButton.Pressed.Border}"/>
160
-
161
81
  <Setter Property="Fill" TargetName="optionMark" Value="{StaticResource RadioButton.Pressed.Glyph}"/>
162
-
163
82
  </Trigger>
164
-
165
83
  <Trigger Property="IsChecked" Value="true">
166
-
167
84
  <Setter Property="Opacity" TargetName="optionMark" Value="1"/>
168
-
169
85
  </Trigger>
170
-
171
86
  <Trigger Property="IsChecked" Value="{x:Null}">
172
-
173
87
  <Setter Property="Opacity" TargetName="optionMark" Value="0.56"/>
174
-
175
88
  </Trigger>
176
-
177
89
  </ControlTemplate.Triggers>
178
-
179
90
  </ControlTemplate>
180
-
181
91
  </Setter.Value>
182
-
183
92
  </Setter>
184
-
185
93
  </Style>
186
-
187
94
  </Window.Resources>
188
-
189
95
  <Grid>
190
-
191
96
  <RadioButton Content="Content" />
192
-
193
97
  </Grid>
194
-
195
98
  </Window>
196
-
197
99
  ```
198
100
 
199
-
200
-
201
101
  出力の際に「すべてに適用」にしておくと、Styleをつけて回る手間が省けます。

1

Windows 10

2021/07/14 01:21

投稿

TN8001
TN8001

スコア9862

test CHANGED
@@ -1,4 +1,4 @@
1
- これで解決するかは不明ですが、Visual Studio 2019で出したStyleを提示しておきます。
1
+ これで解決するかは不明ですが、Windows 10 & Visual Studio 2019で出したStyleを提示しておきます。
2
2
 
3
3
 
4
4