-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
VisualStateManager.xml
580 lines (529 loc) · 51 KB
/
VisualStateManager.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
<Type Name="VisualStateManager" FullName="System.Windows.VisualStateManager">
<TypeSignature Language="C#" Value="public class VisualStateManager : System.Windows.DependencyObject" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit VisualStateManager extends System.Windows.DependencyObject" />
<TypeSignature Language="DocId" Value="T:System.Windows.VisualStateManager" />
<TypeSignature Language="VB.NET" Value="Public Class VisualStateManager
Inherits DependencyObject" />
<TypeSignature Language="F#" Value="type VisualStateManager = class
 inherit DependencyObject" />
<TypeSignature Language="C++ CLI" Value="public ref class VisualStateManager : System::Windows::DependencyObject" />
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Windows.DependencyObject</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Manages states and the logic for transitioning between states for controls.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Windows.VisualStateManager> enables you to specify states for a control, the appearance of a control when it is in a certain state, and when a control changes states. For example, a <xref:System.Windows.Controls.Button> might have a slightly different appearance when it is pressed than when it is not pressed. Two states that the <xref:System.Windows.Controls.Button> defines correspond to when it is pressed (`"Pressed"`) and when it is not (`"Normal"`). The appearance of a control when it is in a state is defined by a <xref:System.Windows.VisualState>. A <xref:System.Windows.VisualState> contains a collection of <xref:System.Windows.Media.Animation.Storyboard> objects that specify how the control's appearance changes when the control is in that state. You add visual states to a control by setting the `VisualStateManager.VisualStateGroups` attached property on the control. Each <xref:System.Windows.VisualStateGroup> contains a collection of <xref:System.Windows.VisualState> objects that are mutually exclusive. That is, the control is always in exactly one state of in each <xref:System.Windows.VisualStateGroup>.
The <xref:System.Windows.VisualStateManager> also enables you to specify when a control enters a specific state. The method that you should call to change states depends on your scenario. If you create a control that uses the <xref:System.Windows.VisualStateManager> in its <xref:System.Windows.Controls.ControlTemplate>, call the <xref:System.Windows.VisualStateManager.GoToState%2A> method. For more information about how to create controls that use the <xref:System.Windows.VisualStateManager>, see [Creating a Control That Has a Customizable Appearance](/dotnet/framework/wpf/controls/creating-a-control-that-has-a-customizable-appearance). If you use the <xref:System.Windows.VisualStateManager> outside of a <xref:System.Windows.Controls.ControlTemplate> (for example, if you use a <xref:System.Windows.VisualStateManager> in a <xref:System.Windows.Controls.UserControl> or in a single element), call the <xref:System.Windows.VisualStateManager.GoToElementState%2A> method. In either case, the <xref:System.Windows.VisualStateManager> performs the logic that is required to appropriately start and stop the storyboards that are associated with the involved state. For example, suppose that a control defines the states, `State1` and `State2`, each of which has a storyboard associated with it. If the control is in `State1` and you pass `State2` to <xref:System.Windows.VisualStateManager.GoToState%2A> or <xref:System.Windows.VisualStateManager.GoToElementState%2A>, the <xref:System.Windows.VisualStateManager> starts the storyboard in `State2` and stops the storyboard in `State1`.
Controls that are included with Windows Presentation Foundation (WPF) use the <xref:System.Windows.VisualStateManager> to change visual states. When you create a <xref:System.Windows.Controls.ControlTemplate> for a control that is included with WPF, you can add <xref:System.Windows.VisualState> objects to the control's <xref:System.Windows.Controls.ControlTemplate> to specify the control's appearance in a certain state. To find the names of the visual states for the controls that are included with WPF, see [Control Styles and Templates](/dotnet/framework/wpf/controls/control-styles-and-templates). The control's logic handles transitioning between states, so you do not need to do anything other than define the <xref:System.Windows.VisualState> objects in the new <xref:System.Windows.Controls.ControlTemplate>. For more information about how to create control templates for existing controls, see [Customizing the Appearance of an Existing Control by Creating a ControlTemplate](/dotnet/framework/wpf/controls/customizing-the-appearance-of-an-existing-control).
If you want to implement your own logic for transitioning between states, you must inherit from <xref:System.Windows.VisualStateManager>, override the <xref:System.Windows.VisualStateManager.GoToStateCore%2A> method, and set the <xref:System.Windows.VisualStateManager.CustomVisualStateManager%2A?displayProperty=nameWithType> attached property on the control that uses the custom logic.
## Examples
The following example creates a <xref:System.Windows.Shapes.Rectangle> and adds a <xref:System.Windows.VisualStateGroup> named `CommonStates` to the `VisualStateManager.VisualStatesGroups` attached property. The example defines the `MouseOver` and `Normal` <xref:System.Windows.VisualState> objects in the `CommonStates` <xref:System.Windows.VisualStateGroup>. When the user moves the mouse pointer over the <xref:System.Windows.Shapes.Rectangle>, it changes from red to green over one half second. When the user moves the mouse away from the rectangle, the <xref:System.Windows.Controls.Grid> immediately changes back to red. Note that the `Normal` state does not define a <xref:System.Windows.Media.Animation.Storyboard>. A <xref:System.Windows.Media.Animation.Storyboard> is not required because when the <xref:System.Windows.Shapes.Rectangle> transitions from the `MouseOver` state to the `Normal` state, the <xref:System.Windows.Media.Animation.Storyboard> for `MouseOver` is stopped and the <xref:System.Windows.Media.SolidColorBrush.Color%2A> property for the <xref:System.Windows.Media.SolidColorBrush> returns to red.
:::code language="xaml" source="~/snippets/csharp/System.Windows/TemplateVisualStateAttribute/Overview/window1.xaml" id="Snippetvsmnotemplate":::
The following example shows the event handler that is defined in the previous example and calls the <xref:System.Windows.VisualStateManager.GoToElementState%2A> method to transition between states. If the rectangle in the previous example was part of a <xref:System.Windows.Controls.ControlTemplate>, the example would have to call the <xref:System.Windows.VisualStateManager.GoToState%2A> method.
:::code language="csharp" source="~/snippets/csharp/System.Windows/TemplateVisualStateAttribute/Overview/window1.xaml.cs" id="Snippetgotoelementstate":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/vsmcustomcontrol/visualbasic/window1.xaml.vb" id="Snippetgotoelementstate":::
]]></format>
</remarks>
</Docs>
<Members>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public VisualStateManager ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.VisualStateManager.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:
 VisualStateManager();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Windows.VisualStateManager" /> class.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="CustomVisualStateManager">
<MemberSignature Language="C#" Value="see GetCustomVisualStateManager, and SetCustomVisualStateManager" />
<MemberSignature Language="ILAsm" Value="see GetCustomVisualStateManager, and SetCustomVisualStateManager" />
<MemberSignature Language="DocId" Value="P:System.Windows.VisualStateManager.CustomVisualStateManager" />
<MemberSignature Language="VB.NET" Value="see GetCustomVisualStateManager, and SetCustomVisualStateManager" />
<MemberSignature Language="F#" Value="see GetCustomVisualStateManager, and SetCustomVisualStateManager" Usage="see GetCustomVisualStateManager, and SetCustomVisualStateManager" />
<MemberType>AttachedProperty</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Gets or sets the <see cref="T:System.Windows.VisualStateManager" /> object that transitions between the states of a control.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
If <xref:System.Windows.VisualStateManager.CustomVisualStateManager%2A> is `null`, the <xref:System.Windows.VisualStateManager> uses its own logic to transition between states. If you want to implement your own logic for transitioning between states, create a class that inherits from <xref:System.Windows.VisualStateManager> and override the <xref:System.Windows.VisualStateManager.GoToStateCore%2A> method. To use the custom class, set the <xref:System.Windows.VisualStateManager.CustomVisualStateManager%2A> property to an object of your custom type.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="CustomVisualStateManagerProperty">
<MemberSignature Language="C#" Value="public static readonly System.Windows.DependencyProperty CustomVisualStateManagerProperty;" />
<MemberSignature Language="ILAsm" Value=".field public static initonly class System.Windows.DependencyProperty CustomVisualStateManagerProperty" />
<MemberSignature Language="DocId" Value="F:System.Windows.VisualStateManager.CustomVisualStateManagerProperty" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly CustomVisualStateManagerProperty As DependencyProperty " />
<MemberSignature Language="F#" Value=" staticval mutable CustomVisualStateManagerProperty : System.Windows.DependencyProperty" Usage="System.Windows.VisualStateManager.CustomVisualStateManagerProperty" />
<MemberSignature Language="C++ CLI" Value="public: static initonly System::Windows::DependencyProperty ^ CustomVisualStateManagerProperty;" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Windows.DependencyProperty</ReturnType>
</ReturnValue>
<Docs>
<summary>Identifies the <see cref="P:System.Windows.VisualStateManager.CustomVisualStateManager" /> dependency property.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="GetCustomVisualStateManager">
<MemberSignature Language="C#" Value="public static System.Windows.VisualStateManager GetCustomVisualStateManager (System.Windows.FrameworkElement obj);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Windows.VisualStateManager GetCustomVisualStateManager(class System.Windows.FrameworkElement obj) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.VisualStateManager.GetCustomVisualStateManager(System.Windows.FrameworkElement)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetCustomVisualStateManager (obj As FrameworkElement) As VisualStateManager" />
<MemberSignature Language="F#" Value="static member GetCustomVisualStateManager : System.Windows.FrameworkElement -> System.Windows.VisualStateManager" Usage="System.Windows.VisualStateManager.GetCustomVisualStateManager obj" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Windows::VisualStateManager ^ GetCustomVisualStateManager(System::Windows::FrameworkElement ^ obj);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Windows.VisualStateManager</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="obj" Type="System.Windows.FrameworkElement" />
</Parameters>
<Docs>
<param name="obj">The element to get the <see cref="P:System.Windows.VisualStateManager.CustomVisualStateManager" /> attached property from.</param>
<summary>Gets the <see cref="P:System.Windows.VisualStateManager.CustomVisualStateManager" /> attached property.</summary>
<returns>The visual state manager that transitions between the states of a control.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="GetVisualStateGroups">
<MemberSignature Language="C#" Value="public static System.Collections.IList GetVisualStateGroups (System.Windows.FrameworkElement obj);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Collections.IList GetVisualStateGroups(class System.Windows.FrameworkElement obj) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.VisualStateManager.GetVisualStateGroups(System.Windows.FrameworkElement)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetVisualStateGroups (obj As FrameworkElement) As IList" />
<MemberSignature Language="F#" Value="static member GetVisualStateGroups : System.Windows.FrameworkElement -> System.Collections.IList" Usage="System.Windows.VisualStateManager.GetVisualStateGroups obj" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Collections::IList ^ GetVisualStateGroups(System::Windows::FrameworkElement ^ obj);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Collections.IList</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="obj" Type="System.Windows.FrameworkElement" />
</Parameters>
<Docs>
<param name="obj">The element to get the <see cref="P:System.Windows.VisualStateManager.VisualStateGroups" /> attached property from.</param>
<summary>Gets the <see cref="P:System.Windows.VisualStateManager.VisualStateGroups" /> attached property.</summary>
<returns>The collection of <see cref="T:System.Windows.VisualStateGroup" /> objects that is associated with the specified object.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="GoToElementState">
<MemberSignature Language="C#" Value="public static bool GoToElementState (System.Windows.FrameworkElement stateGroupsRoot, string stateName, bool useTransitions);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig bool GoToElementState(class System.Windows.FrameworkElement stateGroupsRoot, string stateName, bool useTransitions) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.VisualStateManager.GoToElementState(System.Windows.FrameworkElement,System.String,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GoToElementState (stateGroupsRoot As FrameworkElement, stateName As String, useTransitions As Boolean) As Boolean" />
<MemberSignature Language="F#" Value="static member GoToElementState : System.Windows.FrameworkElement * string * bool -> bool" Usage="System.Windows.VisualStateManager.GoToElementState (stateGroupsRoot, stateName, useTransitions)" />
<MemberSignature Language="C++ CLI" Value="public:
 static bool GoToElementState(System::Windows::FrameworkElement ^ stateGroupsRoot, System::String ^ stateName, bool useTransitions);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="stateGroupsRoot" Type="System.Windows.FrameworkElement" />
<Parameter Name="stateName" Type="System.String" />
<Parameter Name="useTransitions" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="stateGroupsRoot">The root element that contains the <see cref="T:System.Windows.VisualStateManager" />.</param>
<param name="stateName">The state to transition to.</param>
<param name="useTransitions">
<see langword="true" /> to use a <see cref="T:System.Windows.VisualTransition" /> object to transition between states; otherwise, <see langword="false" />.</param>
<summary>Transitions the element between two states. Use this method to transition states that are defined by an application, rather than defined by a control.</summary>
<returns>
<see langword="true" /> if the control successfully transitioned to the new state; otherwise, <see langword="false" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Call the <xref:System.Windows.VisualStateManager.GoToElementState%2A> method to change states on an element outside of a <xref:System.Windows.Controls.ControlTemplate> (for example, if you use a <xref:System.Windows.VisualStateManager> in a <xref:System.Windows.DataTemplate> or <xref:System.Windows.Window>). Call the <xref:System.Windows.VisualStateManager.GoToState%2A> method if you are changing states in a control that uses the <xref:System.Windows.VisualStateManager> in its <xref:System.Windows.Controls.ControlTemplate>.
## Examples
The following example creates an application that prompts the user to guess a number between 1 and 100. When the user enters a number, the application indicates whether the guess is too high, too low, or correct. The following XAML creates the user interface for the application and defines 4 states: `TooLow`, `TooHigh`, `Correct`, and `Guessing`. When the application begins, it is in the `Guessing` state. .
:::code language="xaml" source="~/snippets/csharp/System.Windows/VisualStateManager/GoToElementState/mainwindow.xaml" id="Snippetgotoelementstatexaml":::
The following code shows the logic of the application. When the user enters a number and clicks the button, the application calls <xref:System.Windows.VisualStateManager.GoToElementState%2A> to transition to `TooHigh`, `TooLow`, or `Correct` to provide feedback to the user about the guess. To try this example, call the `GenerateNumber` method when the application begins.
:::code language="csharp" source="~/snippets/csharp/System.Windows/VisualStateManager/GoToElementState/mainwindow.xaml.cs" id="Snippetgotoelementstatecode":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/vsmgotoelementstate/visualbasic/mainwindow.xaml.vb" id="Snippetgotoelementstatecode":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="stateGroupsRoot" /> is <see langword="null" />.
-or-
<paramref name="stateName" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="GoToState">
<MemberSignature Language="C#" Value="public static bool GoToState (System.Windows.FrameworkElement control, string stateName, bool useTransitions);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig bool GoToState(class System.Windows.FrameworkElement control, string stateName, bool useTransitions) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.VisualStateManager.GoToState(System.Windows.FrameworkElement,System.String,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GoToState (control As FrameworkElement, stateName As String, useTransitions As Boolean) As Boolean" />
<MemberSignature Language="F#" Value="static member GoToState : System.Windows.FrameworkElement * string * bool -> bool" Usage="System.Windows.VisualStateManager.GoToState (control, stateName, useTransitions)" />
<MemberSignature Language="C++ CLI" Value="public:
 static bool GoToState(System::Windows::FrameworkElement ^ control, System::String ^ stateName, bool useTransitions);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="control" Type="System.Windows.FrameworkElement" />
<Parameter Name="stateName" Type="System.String" />
<Parameter Name="useTransitions" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="control">The control to transition between states.</param>
<param name="stateName">The state to transition to.</param>
<param name="useTransitions">
<see langword="true" /> to use a <see cref="T:System.Windows.VisualTransition" /> object to transition between states; otherwise, <see langword="false" />.</param>
<summary>Transitions the control between two states. Use this method to transition states on control that has a <see cref="T:System.Windows.Controls.ControlTemplate" />.</summary>
<returns>
<see langword="true" /> if the control successfully transitioned to the new state; otherwise, <see langword="false" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Call the <xref:System.Windows.VisualStateManager.GoToState%2A> method if you are changing states in a control that uses the <xref:System.Windows.VisualStateManager> in its <xref:System.Windows.Controls.ControlTemplate>. Call the <xref:System.Windows.VisualStateManager.GoToElementState%2A> method to change states on an element outside of a <xref:System.Windows.Controls.ControlTemplate> (for example, if you use a <xref:System.Windows.VisualStateManager> in a <xref:System.Windows.Controls.UserControl> or in a single element).
## Examples
The following example demonstrates a control that uses the <xref:System.Windows.VisualStateManager.GoToState%2A> method to transition between states. For the entire example, see [Creating a Control That Has a Customizable Appearance](/dotnet/framework/wpf/controls/creating-a-control-that-has-a-customizable-appearance).
:::code language="csharp" source="~/snippets/csharp/System.Windows/TemplateVisualStateAttribute/Overview/numericupdown.cs" id="Snippetupdatestates":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/vsmcustomcontrol/visualbasic/numericupdown.vb" id="Snippetupdatestates":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="control" /> is <see langword="null" />.
-or-
<paramref name="stateName" /> is <see langword="null" />.</exception>
</Docs>
</Member>
<Member MemberName="GoToStateCore">
<MemberSignature Language="C#" Value="protected virtual bool GoToStateCore (System.Windows.FrameworkElement control, System.Windows.FrameworkElement stateGroupsRoot, string stateName, System.Windows.VisualStateGroup group, System.Windows.VisualState state, bool useTransitions);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance bool GoToStateCore(class System.Windows.FrameworkElement control, class System.Windows.FrameworkElement stateGroupsRoot, string stateName, class System.Windows.VisualStateGroup group, class System.Windows.VisualState state, bool useTransitions) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.VisualStateManager.GoToStateCore(System.Windows.FrameworkElement,System.Windows.FrameworkElement,System.String,System.Windows.VisualStateGroup,System.Windows.VisualState,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Protected Overridable Function GoToStateCore (control As FrameworkElement, stateGroupsRoot As FrameworkElement, stateName As String, group As VisualStateGroup, state As VisualState, useTransitions As Boolean) As Boolean" />
<MemberSignature Language="F#" Value="abstract member GoToStateCore : System.Windows.FrameworkElement * System.Windows.FrameworkElement * string * System.Windows.VisualStateGroup * System.Windows.VisualState * bool -> bool
override this.GoToStateCore : System.Windows.FrameworkElement * System.Windows.FrameworkElement * string * System.Windows.VisualStateGroup * System.Windows.VisualState * bool -> bool" Usage="visualStateManager.GoToStateCore (control, stateGroupsRoot, stateName, group, state, useTransitions)" />
<MemberSignature Language="C++ CLI" Value="protected:
 virtual bool GoToStateCore(System::Windows::FrameworkElement ^ control, System::Windows::FrameworkElement ^ stateGroupsRoot, System::String ^ stateName, System::Windows::VisualStateGroup ^ group, System::Windows::VisualState ^ state, bool useTransitions);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="control" Type="System.Windows.FrameworkElement" />
<Parameter Name="stateGroupsRoot" Type="System.Windows.FrameworkElement" />
<Parameter Name="stateName" Type="System.String" />
<Parameter Name="group" Type="System.Windows.VisualStateGroup" />
<Parameter Name="state" Type="System.Windows.VisualState" />
<Parameter Name="useTransitions" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="control">The control to transition between states.</param>
<param name="stateGroupsRoot">The root element that contains the <see cref="T:System.Windows.VisualStateManager" />.</param>
<param name="stateName">The name of the state to transition to.</param>
<param name="group">The <see cref="T:System.Windows.VisualStateGroup" /> that the state belongs to.</param>
<param name="state">The representation of the state to transition to.</param>
<param name="useTransitions">
<see langword="true" /> to use a <see cref="T:System.Windows.VisualTransition" /> object to transition between states; otherwise, <see langword="false" />.</param>
<summary>Transitions a control between states.</summary>
<returns>
<see langword="true" /> if the control successfully transitioned to the new state; otherwise, <see langword="false" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Windows.VisualStateManager.GoToStateCore%2A> method performs the logic necessary to appropriately start and stop the storyboards that are associated with a transition. When a control calls <xref:System.Windows.VisualStateManager.GoToState%2A> to change its state, the <xref:System.Windows.VisualStateManager> does the following:
- First, if the <xref:System.Windows.VisualState> that the control is transitioning to has a <xref:System.Windows.Media.Animation.Storyboard>, the storyboard begins. Then, if the <xref:System.Windows.VisualState> that the control is coming from has a <xref:System.Windows.Media.Animation.Storyboard>, the storyboard ends.
- If the control is already in the `stateName` state, <xref:System.Windows.VisualStateManager.GoToState%2A> takes no action and returns `true`.
- If `stateName` does not exist in the <xref:System.Windows.Controls.ControlTemplate> of `control`, <xref:System.Windows.VisualStateManager.GoToState%2A> takes no action and returns `false`.
You can implement your own <xref:System.Windows.VisualStateManager> to provide different logic for transitioning between states. For example, you can change the logic described previously, or you can provide logic to transition between custom animation types. To implement a <xref:System.Windows.VisualStateManager>, create a class that inherits from <xref:System.Windows.VisualStateManager> and override the <xref:System.Windows.VisualStateManager.GoToStateCore%2A> method. To use the custom class, set the <xref:System.Windows.VisualStateManager.CustomVisualStateManager%2A> property to an object of your custom type.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="RaiseCurrentStateChanged">
<MemberSignature Language="C#" Value="protected void RaiseCurrentStateChanged (System.Windows.VisualStateGroup stateGroup, System.Windows.VisualState oldState, System.Windows.VisualState newState, System.Windows.FrameworkElement control, System.Windows.FrameworkElement stateGroupsRoot);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig instance void RaiseCurrentStateChanged(class System.Windows.VisualStateGroup stateGroup, class System.Windows.VisualState oldState, class System.Windows.VisualState newState, class System.Windows.FrameworkElement control, class System.Windows.FrameworkElement stateGroupsRoot) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.VisualStateManager.RaiseCurrentStateChanged(System.Windows.VisualStateGroup,System.Windows.VisualState,System.Windows.VisualState,System.Windows.FrameworkElement,System.Windows.FrameworkElement)" />
<MemberSignature Language="VB.NET" Value="Protected Sub RaiseCurrentStateChanged (stateGroup As VisualStateGroup, oldState As VisualState, newState As VisualState, control As FrameworkElement, stateGroupsRoot As FrameworkElement)" />
<MemberSignature Language="F#" Value="member this.RaiseCurrentStateChanged : System.Windows.VisualStateGroup * System.Windows.VisualState * System.Windows.VisualState * System.Windows.FrameworkElement * System.Windows.FrameworkElement -> unit" Usage="visualStateManager.RaiseCurrentStateChanged (stateGroup, oldState, newState, control, stateGroupsRoot)" />
<MemberSignature Language="C++ CLI" Value="protected:
 void RaiseCurrentStateChanged(System::Windows::VisualStateGroup ^ stateGroup, System::Windows::VisualState ^ oldState, System::Windows::VisualState ^ newState, System::Windows::FrameworkElement ^ control, System::Windows::FrameworkElement ^ stateGroupsRoot);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="stateGroup" Type="System.Windows.VisualStateGroup" />
<Parameter Name="oldState" Type="System.Windows.VisualState" />
<Parameter Name="newState" Type="System.Windows.VisualState" />
<Parameter Name="control" Type="System.Windows.FrameworkElement" />
<Parameter Name="stateGroupsRoot" Type="System.Windows.FrameworkElement" />
</Parameters>
<Docs>
<param name="stateGroup">The object that the <see cref="E:System.Windows.VisualStateGroup.CurrentStateChanging" /> event occurred on.</param>
<param name="oldState">The state that the control is transitioning from.</param>
<param name="newState">The state that the control is transitioning to.</param>
<param name="control">The control that is transitioning states.</param>
<param name="stateGroupsRoot">The root element that contains the <see cref="T:System.Windows.VisualStateManager" />.</param>
<summary>Raises the <see cref="E:System.Windows.VisualStateGroup.CurrentStateChanging" /> event on the specified <see cref="T:System.Windows.VisualStateGroup" /> object.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When the <xref:System.Windows.VisualStateGroup> is set on the <xref:System.Windows.Controls.ControlTemplate> of a control, the `control` parameter is set to the control that owns <xref:System.Windows.Controls.ControlTemplate>. When the <xref:System.Windows.VisualStateGroup> is set on a <xref:System.Windows.FrameworkElement>, `control` is `null` and you should use the `stateGroupsRoot` parameter.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="stateGroupsRoot" /> is <see langword="null" />.
-or-
<paramref name="newState" /> is <see langword="null" />.</exception>
<block subset="none" type="overrides">
<para>When overriding <see cref="M:System.Windows.VisualStateManager.RaiseCurrentStateChanged(System.Windows.VisualStateGroup,System.Windows.VisualState,System.Windows.VisualState,System.Windows.FrameworkElement,System.Windows.FrameworkElement)" /> in a derived class, be sure to call the base class' <see cref="M:System.Windows.VisualStateManager.RaiseCurrentStateChanged(System.Windows.VisualStateGroup,System.Windows.VisualState,System.Windows.VisualState,System.Windows.FrameworkElement,System.Windows.FrameworkElement)" /> method so that registered delegates receive the event.</para>
</block>
</Docs>
</Member>
<Member MemberName="RaiseCurrentStateChanging">
<MemberSignature Language="C#" Value="protected void RaiseCurrentStateChanging (System.Windows.VisualStateGroup stateGroup, System.Windows.VisualState oldState, System.Windows.VisualState newState, System.Windows.FrameworkElement control, System.Windows.FrameworkElement stateGroupsRoot);" />
<MemberSignature Language="ILAsm" Value=".method familyhidebysig instance void RaiseCurrentStateChanging(class System.Windows.VisualStateGroup stateGroup, class System.Windows.VisualState oldState, class System.Windows.VisualState newState, class System.Windows.FrameworkElement control, class System.Windows.FrameworkElement stateGroupsRoot) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.VisualStateManager.RaiseCurrentStateChanging(System.Windows.VisualStateGroup,System.Windows.VisualState,System.Windows.VisualState,System.Windows.FrameworkElement,System.Windows.FrameworkElement)" />
<MemberSignature Language="VB.NET" Value="Protected Sub RaiseCurrentStateChanging (stateGroup As VisualStateGroup, oldState As VisualState, newState As VisualState, control As FrameworkElement, stateGroupsRoot As FrameworkElement)" />
<MemberSignature Language="F#" Value="member this.RaiseCurrentStateChanging : System.Windows.VisualStateGroup * System.Windows.VisualState * System.Windows.VisualState * System.Windows.FrameworkElement * System.Windows.FrameworkElement -> unit" Usage="visualStateManager.RaiseCurrentStateChanging (stateGroup, oldState, newState, control, stateGroupsRoot)" />
<MemberSignature Language="C++ CLI" Value="protected:
 void RaiseCurrentStateChanging(System::Windows::VisualStateGroup ^ stateGroup, System::Windows::VisualState ^ oldState, System::Windows::VisualState ^ newState, System::Windows::FrameworkElement ^ control, System::Windows::FrameworkElement ^ stateGroupsRoot);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="stateGroup" Type="System.Windows.VisualStateGroup" />
<Parameter Name="oldState" Type="System.Windows.VisualState" />
<Parameter Name="newState" Type="System.Windows.VisualState" />
<Parameter Name="control" Type="System.Windows.FrameworkElement" />
<Parameter Name="stateGroupsRoot" Type="System.Windows.FrameworkElement" />
</Parameters>
<Docs>
<param name="stateGroup">The object that the <see cref="E:System.Windows.VisualStateGroup.CurrentStateChanging" /> event occurred on.</param>
<param name="oldState">The state that the control is transitioning from.</param>
<param name="newState">The state that the control is transitioning to.</param>
<param name="control">The control that is transitioning states.</param>
<param name="stateGroupsRoot">The root element that contains the <see cref="T:System.Windows.VisualStateManager" />.</param>
<summary>Raises the <see cref="E:System.Windows.VisualStateGroup.CurrentStateChanging" /> event on the specified <see cref="T:System.Windows.VisualStateGroup" /> object.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
When the <xref:System.Windows.VisualStateGroup> is set on the <xref:System.Windows.Controls.ControlTemplate> of a control, the `control` parameter is set to the control that owns <xref:System.Windows.Controls.ControlTemplate>. When the <xref:System.Windows.VisualStateGroup> is set on a <xref:System.Windows.FrameworkElement>, `control` is `null` and you should use the `stateGroupsRoot` parameter.
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">
<paramref name="stateGroupsRoot" /> is <see langword="null" />.
-or-
<paramref name="newState" /> is <see langword="null" />.</exception>
<block subset="none" type="overrides">
<para>When overriding <see cref="M:System.Windows.VisualStateManager.RaiseCurrentStateChanging(System.Windows.VisualStateGroup,System.Windows.VisualState,System.Windows.VisualState,System.Windows.FrameworkElement,System.Windows.FrameworkElement)" /> in a derived class, be sure to call the base class' <see cref="M:System.Windows.VisualStateManager.RaiseCurrentStateChanging(System.Windows.VisualStateGroup,System.Windows.VisualState,System.Windows.VisualState,System.Windows.FrameworkElement,System.Windows.FrameworkElement)" /> method so that registered delegates receive the event.</para>
</block>
</Docs>
</Member>
<Member MemberName="SetCustomVisualStateManager">
<MemberSignature Language="C#" Value="public static void SetCustomVisualStateManager (System.Windows.FrameworkElement obj, System.Windows.VisualStateManager value);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void SetCustomVisualStateManager(class System.Windows.FrameworkElement obj, class System.Windows.VisualStateManager value) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.VisualStateManager.SetCustomVisualStateManager(System.Windows.FrameworkElement,System.Windows.VisualStateManager)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub SetCustomVisualStateManager (obj As FrameworkElement, value As VisualStateManager)" />
<MemberSignature Language="F#" Value="static member SetCustomVisualStateManager : System.Windows.FrameworkElement * System.Windows.VisualStateManager -> unit" Usage="System.Windows.VisualStateManager.SetCustomVisualStateManager (obj, value)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void SetCustomVisualStateManager(System::Windows::FrameworkElement ^ obj, System::Windows::VisualStateManager ^ value);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="obj" Type="System.Windows.FrameworkElement" />
<Parameter Name="value" Type="System.Windows.VisualStateManager" />
</Parameters>
<Docs>
<param name="obj">The object to set the property on.</param>
<param name="value">The visual state manager that transitions between the states of a control.</param>
<summary>Sets the <see cref="P:System.Windows.VisualStateManager.CustomVisualStateManager" /> attached property.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="VisualStateGroups">
<MemberSignature Language="C#" Value="see GetVisualStateGroups" />
<MemberSignature Language="ILAsm" Value="see GetVisualStateGroups" />
<MemberSignature Language="DocId" Value="P:System.Windows.VisualStateManager.VisualStateGroups" />
<MemberSignature Language="VB.NET" Value="see GetVisualStateGroups" />
<MemberSignature Language="F#" Value="see GetVisualStateGroups" Usage="see GetVisualStateGroups" />
<MemberType>AttachedProperty</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Gets or sets a collection of <see cref="T:System.Windows.VisualStateGroup" /> objects.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Each <xref:System.Windows.VisualStateGroup> contains a collection of <xref:System.Windows.VisualState> objects. A <xref:System.Windows.VisualState> contains a collection of <xref:System.Windows.Media.Animation.Storyboard> objects that specify how the control's appearance changes when the control is in a certain state. For example, a <xref:System.Windows.Controls.Button> might have a slightly different appearance when it is pressed than when it is not pressed. Two states that the <xref:System.Windows.Controls.Button> defines correspond to when it is pressed (`"Pressed"`) and when it is not (`"Normal"`).
You add <xref:System.Windows.VisualState> to a control by setting the <xref:System.Windows.VisualStateManager.VisualStateGroups%2A> attached property on the control. You put states that are mutually exclusive to each other in the same <xref:System.Windows.VisualStateGroup>. For example, the <xref:System.Windows.Controls.CheckBox> has two <xref:System.Windows.VisualStateGroup> objects. One contains the states, `Normal`, `MouseOver`, `Pressed`, and `Disabled`. The other contains the states, `Checked`, `UnChecked`, and `Indeterminate`. The <xref:System.Windows.Controls.CheckBox> can be in states `MouseOver` and `UnChecked` at the same time, but it cannot be in the `MouseOver` and `Pressed` states at the same time.
Although you can add <xref:System.Windows.VisualState> objects to any element, they are a particularly useful way to enable others to redefine the visual behavior of a <xref:System.Windows.Controls.Control>. If you create a custom control that uses a <xref:System.Windows.Controls.ControlTemplate>, you can specify which states that control can be in by adding a <xref:System.Windows.TemplateVisualStateAttribute> on its class definition. Then anyone who creates a new <xref:System.Windows.Controls.ControlTemplate> for your control can add <xref:System.Windows.VisualState> objects to the template. States with the same <xref:System.Windows.TemplateVisualStateAttribute.GroupName%2A?displayProperty=fullName> belong in the same <xref:System.Windows.VisualStateGroup>.
For more information about how to use <xref:System.Windows.VisualStateGroup> objects in a <xref:System.Windows.Controls.ControlTemplate>, see [Customizing the Appearance of an Existing Control by Creating a ControlTemplate](/dotnet/framework/wpf/controls/customizing-the-appearance-of-an-existing-control). For more information about how to create controls that use the <xref:System.Windows.VisualStateManager>, see [Creating a Control That Has a Customizable Appearance](/dotnet/framework/wpf/controls/creating-a-control-that-has-a-customizable-appearance).
## Examples
The following example creates a simple <xref:System.Windows.Controls.ControlTemplate> for a <xref:System.Windows.Controls.Button> that contains one <xref:System.Windows.Controls.Grid>. It also contains a <xref:System.Windows.VisualStateGroup> named `CommonStates`, which defines the `MouseOver` and `Normal` states. The <xref:System.Windows.VisualStateGroup> also has a <xref:System.Windows.VisualTransition> that specifies that it takes one half second for the <xref:System.Windows.Controls.Grid> to change from green to red when the user moves the mouse pointer over the <xref:System.Windows.Controls.Button>.
:::code language="xaml" source="~/snippets/csharp/System.Windows/VisualState/Overview/window1.xaml" id="Snippet11":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="VisualStateGroupsProperty">
<MemberSignature Language="C#" Value="public static readonly System.Windows.DependencyProperty VisualStateGroupsProperty;" />
<MemberSignature Language="ILAsm" Value=".field public static initonly class System.Windows.DependencyProperty VisualStateGroupsProperty" />
<MemberSignature Language="DocId" Value="F:System.Windows.VisualStateManager.VisualStateGroupsProperty" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly VisualStateGroupsProperty As DependencyProperty " />
<MemberSignature Language="F#" Value=" staticval mutable VisualStateGroupsProperty : System.Windows.DependencyProperty" Usage="System.Windows.VisualStateManager.VisualStateGroupsProperty" />
<MemberSignature Language="C++ CLI" Value="public: static initonly System::Windows::DependencyProperty ^ VisualStateGroupsProperty;" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationFramework</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>5.0.0.0</AssemblyVersion>
<AssemblyVersion>6.0.0.0</AssemblyVersion>
<AssemblyVersion>7.0.0.0</AssemblyVersion>
<AssemblyVersion>8.0.0.0</AssemblyVersion>
<AssemblyVersion>9.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Windows.DependencyProperty</ReturnType>
</ReturnValue>
<Docs>
<summary>Identifies the <see cref="P:System.Windows.VisualStateManager.VisualStateGroups" /> dependency property.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
</Members>
</Type>