回答編集履歴

1

見直しキャンペーン中

2023/07/23 09:20

投稿

TN8001
TN8001

スコア9862

test CHANGED
@@ -1,319 +1,160 @@
1
1
  > 最悪、ControlTemplate自体をコピーして、該当部分を書き換える?と思うのですが、もっとスマートな方法がある気がしてなりません。
2
-
3
-
4
2
 
5
3
  `Style`で`BasedOn`するような手軽な方法は、`Template`では残念ながら無いです。
6
4
 
7
-
8
-
9
5
  今回の例ですと`ItemContainerStyle`の`Template`で、`MaterialDesignComboBoxItemTemplate`をほぼコピペすることになります。
10
6
 
11
-
12
-
13
- ```xaml
7
+ ```xml
14
-
15
8
  <Window
16
-
17
9
  x:Class="Questions302763.MainWindow"
18
-
19
10
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
20
-
21
11
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
22
-
23
12
  xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
24
-
25
13
  Width="800"
26
-
27
14
  Height="450">
28
-
29
15
  <Window.Resources>
30
-
31
16
  <Style BasedOn="{StaticResource MaterialDesignComboBox}" TargetType="{x:Type ComboBox}">
32
-
33
17
  <Setter Property="ItemContainerStyle">
34
-
35
18
  <Setter.Value>
36
-
37
19
  <Style BasedOn="{StaticResource MaterialDesignComboBoxItemSelectedCollapsedStyle}" TargetType="{x:Type ComboBoxItem}">
38
-
39
20
  <Setter Property="Template">
40
-
41
21
  <Setter.Value>
42
-
43
22
  <ControlTemplate TargetType="{x:Type ComboBoxItem}">
44
-
45
23
  <Grid x:Name="GridWrapper">
46
-
47
24
  <Grid.RowDefinitions>
48
-
49
25
  <RowDefinition Height="Auto" />
50
-
51
26
  </Grid.RowDefinitions>
52
27
 
53
-
54
-
55
28
  <Border
56
-
57
29
  x:Name="BackBorder"
58
-
59
30
  Background="{TemplateBinding Background}"
60
-
61
31
  BorderBrush="{TemplateBinding BorderBrush}"
62
-
63
32
  BorderThickness="{TemplateBinding BorderThickness}"
64
-
65
- SnapsToDevicePixels="True" />
66
-
67
-
68
-
69
- <Border
70
-
71
- x:Name="MouseOverBorder"
72
-
73
- Background="{TemplateBinding Foreground,
74
-
75
- Converter={StaticResource BrushRoundConverter}}"
76
-
77
- BorderBrush="{TemplateBinding BorderBrush}"
78
-
79
- BorderThickness="{TemplateBinding BorderThickness}"
80
-
81
- Opacity="0"
82
-
83
33
  SnapsToDevicePixels="True" />
84
34
 
85
35
  <Border
86
-
36
+ x:Name="MouseOverBorder"
37
+ Background="{TemplateBinding Foreground,
38
+ Converter={StaticResource BrushRoundConverter}}"
39
+ BorderBrush="{TemplateBinding BorderBrush}"
40
+ BorderThickness="{TemplateBinding BorderThickness}"
41
+ Opacity="0"
42
+ SnapsToDevicePixels="True" />
43
+ <Border
87
44
  x:Name="SelectedBorder"
88
-
89
45
  Background="{TemplateBinding Foreground,
90
-
91
46
  Converter={StaticResource BrushRoundConverter}}"
92
-
93
47
  Opacity="0"
94
-
95
48
  RenderTransformOrigin="0.5,0.5" />
96
-
97
49
  <materialDesign:Ripple
98
-
99
50
  Padding="{TemplateBinding Padding}"
100
-
101
51
  HorizontalAlignment="Stretch"
102
-
103
52
  VerticalAlignment="Stretch"
104
-
105
53
  HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
106
-
107
54
  VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
108
-
109
55
  Content="{TemplateBinding Content}"
110
-
111
56
  ContentTemplate="{TemplateBinding ContentTemplate}"
112
-
113
57
  ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
114
-
115
58
  Feedback="{TemplateBinding Foreground,
116
-
117
59
  Converter={StaticResource BrushRoundConverter}}"
118
-
119
60
  Focusable="False"
120
-
121
61
  RecognizesAccessKey="False"
122
-
123
62
  SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
124
-
125
63
  <VisualStateManager.VisualStateGroups>
126
-
127
64
  <VisualStateGroup Name="CommonStates">
128
-
129
65
  <VisualStateGroup.Transitions>
130
-
131
66
  <VisualTransition GeneratedDuration="0:0:0.1" To="Normal">
132
-
133
67
  <VisualTransition.GeneratedEasingFunction>
134
-
135
68
  <CircleEase EasingMode="EaseOut" />
136
-
137
69
  </VisualTransition.GeneratedEasingFunction>
138
-
139
70
  </VisualTransition>
140
-
141
71
  </VisualStateGroup.Transitions>
142
-
143
72
  <VisualState Name="Normal" />
144
-
145
73
  <VisualState Name="MouseOver">
146
-
147
74
  <Storyboard>
148
-
149
75
  <DoubleAnimation
150
-
151
76
  Storyboard.TargetName="MouseOverBorder"
152
-
153
77
  Storyboard.TargetProperty="Opacity"
154
-
155
78
  To="0.1"
156
-
157
79
  Duration="0" />
158
-
159
80
  </Storyboard>
160
-
161
81
  </VisualState>
162
-
163
82
  </VisualStateGroup>
164
-
165
83
  <VisualStateGroup Name="SelectionStates">
166
-
167
84
  <VisualStateGroup.Transitions>
168
-
169
85
  <VisualTransition GeneratedDuration="0:0:0.1" />
170
-
171
86
  </VisualStateGroup.Transitions>
172
-
173
87
  <VisualState Name="Selected">
174
-
175
88
  <Storyboard>
176
-
177
89
  <DoubleAnimation
178
-
179
90
  Storyboard.TargetName="SelectedBorder"
180
-
181
91
  Storyboard.TargetProperty="Opacity"
182
-
183
92
  To="0.18"
184
-
185
93
  Duration="0" />
186
-
187
94
  </Storyboard>
188
-
189
95
  </VisualState>
190
-
191
96
  <VisualState Name="Unselected" />
192
-
193
97
  </VisualStateGroup>
194
-
195
98
  <VisualStateGroup Name="FocusStates">
196
-
197
99
  <VisualStateGroup.Transitions>
198
-
199
100
  <VisualTransition GeneratedDuration="0:0:0.1" To="Unfocused" />
200
-
201
101
  </VisualStateGroup.Transitions>
202
-
203
102
  <VisualState Name="Focused">
204
-
205
103
  <Storyboard>
206
-
207
104
  <DoubleAnimation
208
-
209
105
  Storyboard.TargetName="MouseOverBorder"
210
-
211
106
  Storyboard.TargetProperty="Opacity"
212
-
213
107
  To="0.1"
214
-
215
108
  Duration="0" />
216
-
217
109
  </Storyboard>
218
-
219
110
  </VisualState>
220
-
221
111
  <VisualState Name="Unfocused" />
222
-
223
112
  </VisualStateGroup>
224
-
225
113
  </VisualStateManager.VisualStateGroups>
226
-
227
114
  </Grid>
228
-
229
115
  <ControlTemplate.Triggers>
230
-
231
116
  <Trigger Property="IsEnabled" Value="False">
232
-
233
117
  <Setter TargetName="GridWrapper" Property="Opacity" Value="0.56" />
234
-
235
118
  </Trigger>
236
-
237
119
  <MultiTrigger>
238
-
239
120
  <MultiTrigger.Conditions>
240
-
241
121
  <Condition Property="Tag" Value="{StaticResource AllowCollapse}" />
242
-
243
122
  <Condition Property="IsSelected" Value="True" />
244
-
245
123
  </MultiTrigger.Conditions>
246
-
247
124
  <Setter Property="Height" Value="0" />
248
-
249
125
  </MultiTrigger>
250
-
251
126
  </ControlTemplate.Triggers>
252
-
253
127
  </ControlTemplate>
254
-
255
128
  </Setter.Value>
256
-
257
129
  </Setter>
258
-
259
130
  </Style>
260
-
261
131
  </Setter.Value>
262
-
263
132
  </Setter>
264
-
265
133
  </Style>
266
-
267
134
  </Window.Resources>
268
-
269
135
  <Grid>
270
-
271
136
  <StackPanel>
272
-
273
137
  <GroupBox Header="ノーマル">
274
-
275
138
  <ComboBox Style="{StaticResource MaterialDesignComboBox}">
276
-
277
139
  <ComboBoxItem>aaa</ComboBoxItem>
278
-
279
140
  <ComboBoxItem>bbb</ComboBoxItem>
280
-
281
141
  <ComboBoxItem>ccc</ComboBoxItem>
282
-
283
142
  </ComboBox>
284
-
285
143
  </GroupBox>
286
144
 
287
-
288
-
289
145
  <GroupBox Header="キビキビ">
290
-
291
146
  <ComboBox>
292
-
293
147
  <ComboBoxItem>aaa</ComboBoxItem>
294
-
295
148
  <ComboBoxItem>bbb</ComboBoxItem>
296
-
297
149
  <ComboBoxItem>ccc</ComboBoxItem>
298
-
299
150
  </ComboBox>
300
-
301
151
  </GroupBox>
302
-
303
152
  </StackPanel>
304
-
305
153
  </Grid>
306
-
307
154
  </Window>
308
-
309
155
  ```
310
-
311
-
312
156
 
313
157
  ---
314
158
 
315
-
316
-
317
159
  s.promptさんとまったく同じことを思っている方はいるようですが、クローズしています(前向きに検討中なのか・やる気はないのかは、自動翻訳では読み取れなかったです^^;
318
-
319
160
  [Adding support for customization of visualtransition duration of combobox item to normal state by koutinho · Pull Request #1290 · MaterialDesignInXAML/MaterialDesignInXamlToolkit](https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/pull/1290)