-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
EventManager.xml
281 lines (253 loc) · 20.4 KB
/
EventManager.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
<Type Name="EventManager" FullName="System.Windows.EventManager">
<TypeSignature Language="C#" Value="public static class EventManager" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed beforefieldinit EventManager extends System.Object" />
<TypeSignature Language="DocId" Value="T:System.Windows.EventManager" />
<TypeSignature Language="VB.NET" Value="Public Class EventManager" />
<TypeSignature Language="F#" Value="type EventManager = class" />
<TypeSignature Language="C++ CLI" Value="public ref class EventManager abstract sealed" />
<AssemblyInfo>
<AssemblyName>PresentationCore</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<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.Object</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Provides event-related utility methods that register routed events for class owners and add class handlers.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This class is most commonly used to register a new routed event, with <xref:System.Windows.EventManager.RegisterRoutedEvent%2A>.
The second most common API usage is <xref:System.Windows.EventManager.RegisterClassHandler%2A>. You use this method to enable class handling of a routed event on the class, or an attached event. For details, see [Marking Routed Events as Handled, and Class Handling](/dotnet/framework/wpf/advanced/marking-routed-events-as-handled-and-class-handling).
## Examples
The following example show how to use this class to register a new routed event as a class member, along with the routed event "wrapper" technique of overriding the add and remove implementations for a CLR event.
:::code language="csharp" source="~/snippets/csharp/System.Windows/CoerceValueCallback/Overview/default.xaml.cs" id="Snippeteventmanagerclass":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/DPCustom/visualbasic/default.xaml.vb" id="Snippeteventmanagerclass":::
]]></format>
</remarks>
</Docs>
<Members>
<Member MemberName="GetRoutedEvents">
<MemberSignature Language="C#" Value="public static System.Windows.RoutedEvent[] GetRoutedEvents ();" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Windows.RoutedEvent[] GetRoutedEvents() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.EventManager.GetRoutedEvents" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetRoutedEvents () As RoutedEvent()" />
<MemberSignature Language="F#" Value="static member GetRoutedEvents : unit -> System.Windows.RoutedEvent[]" Usage="System.Windows.EventManager.GetRoutedEvents " />
<MemberSignature Language="C++ CLI" Value="public:
 static cli::array <System::Windows::RoutedEvent ^> ^ GetRoutedEvents();" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationCore</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<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.RoutedEvent[]</ReturnType>
</ReturnValue>
<Parameters />
<Docs>
<summary>Returns identifiers for routed events that have been registered to the event system.</summary>
<returns>An array of type <see cref="T:System.Windows.RoutedEvent" /> that contains the registered objects.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
More <xref:System.Windows.RoutedEvent> objects can be registered later. This method gets a snapshot and the collection of routed events is writeable throughout an application's lifetime. The collection returned might be quite large. Even just counting the events that are part of the WPF APIs, the collection count is in the high hundreds.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="GetRoutedEventsForOwner">
<MemberSignature Language="C#" Value="public static System.Windows.RoutedEvent[] GetRoutedEventsForOwner (Type ownerType);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Windows.RoutedEvent[] GetRoutedEventsForOwner(class System.Type ownerType) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.EventManager.GetRoutedEventsForOwner(System.Type)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function GetRoutedEventsForOwner (ownerType As Type) As RoutedEvent()" />
<MemberSignature Language="F#" Value="static member GetRoutedEventsForOwner : Type -> System.Windows.RoutedEvent[]" Usage="System.Windows.EventManager.GetRoutedEventsForOwner ownerType" />
<MemberSignature Language="C++ CLI" Value="public:
 static cli::array <System::Windows::RoutedEvent ^> ^ GetRoutedEventsForOwner(Type ^ ownerType);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationCore</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<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.RoutedEvent[]</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="ownerType" Type="System.Type" />
</Parameters>
<Docs>
<param name="ownerType">The type to start the search with. Base classes are included in the search.</param>
<summary>Finds all routed event identifiers for events that are registered with the provided owner type.</summary>
<returns>An array of matching routed event identifiers if any match is found; otherwise, <see langword="null" />.</returns>
<remarks>To be added.</remarks>
</Docs>
</Member>
<MemberGroup MemberName="RegisterClassHandler">
<AssemblyInfo>
<AssemblyName>PresentationCore</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Registers a class handler for a particular routed event.</summary>
</Docs>
</MemberGroup>
<Member MemberName="RegisterClassHandler">
<MemberSignature Language="C#" Value="public static void RegisterClassHandler (Type classType, System.Windows.RoutedEvent routedEvent, Delegate handler);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void RegisterClassHandler(class System.Type classType, class System.Windows.RoutedEvent routedEvent, class System.Delegate handler) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.EventManager.RegisterClassHandler(System.Type,System.Windows.RoutedEvent,System.Delegate)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub RegisterClassHandler (classType As Type, routedEvent As RoutedEvent, handler As Delegate)" />
<MemberSignature Language="F#" Value="static member RegisterClassHandler : Type * System.Windows.RoutedEvent * Delegate -> unit" Usage="System.Windows.EventManager.RegisterClassHandler (classType, routedEvent, handler)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void RegisterClassHandler(Type ^ classType, System::Windows::RoutedEvent ^ routedEvent, Delegate ^ handler);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationCore</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<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.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="classType" Type="System.Type" />
<Parameter Name="routedEvent" Type="System.Windows.RoutedEvent" />
<Parameter Name="handler" Type="System.Delegate" />
</Parameters>
<Docs>
<param name="classType">The type of the class that is declaring class handling.</param>
<param name="routedEvent">The routed event identifier of the event to handle.</param>
<param name="handler">A reference to the class handler implementation.</param>
<summary>Registers a class handler for a particular routed event.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Class handling is a feature that is available for routed events, including attached events that are implemented with routed event backing. A class handler is like a static handler that exists for all instances of the class. Because the handler is static, you cannot change instance properties directly with a class handler, but you can access instances through the `sender` parameter and/or the event data.
Class handlers are invoked before instance handlers. You can implement a class handler that has the behavior of marking the event as handled. Therefore, instance handlers for a class-handled event are not invoked unless the instance handlers register specifically for handled events.
Many of the WPF base element events provide class handling virtual methods. By overriding these methods in classes that inherit the base classes, you can implement class handling without calling <xref:System.Windows.EventManager.RegisterClassHandler%2A> in static constructors. These class handling methods typically exist for input events and have names that start with "On" and end with the name of the event being class handled.
For more information about class handling, see [Marking Routed Events as Handled, and Class Handling](/dotnet/framework/wpf/advanced/marking-routed-events-as-handled-and-class-handling).
Using this signature, class handlers will be registered to invoke only in response to unhandled events. You can also register class handlers to invoke even if the event arguments are marked handled, by using the <xref:System.Windows.EventManager.RegisterClassHandler%28System.Type%2CSystem.Windows.RoutedEvent%2CSystem.Delegate%2CSystem.Boolean%29> signature, with `handledEventsToo` set to `true`.
## Examples
The following example adds a handler for <xref:System.Windows.UIElement.PreviewMouseRightButtonDownEvent>, calling <xref:System.Windows.EventManager.RegisterClassHandler%2A>.
:::code language="csharp" source="~/snippets/csharp/System.Windows/EventManager/RegisterClassHandler/class1.cs" id="Snippetstaticandregisterclasshandler":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/ClassHandling/visualbasic/sdksamplelibrary/class1.vb" id="Snippetstaticandregisterclasshandler":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="RegisterClassHandler">
<MemberSignature Language="C#" Value="public static void RegisterClassHandler (Type classType, System.Windows.RoutedEvent routedEvent, Delegate handler, bool handledEventsToo);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig void RegisterClassHandler(class System.Type classType, class System.Windows.RoutedEvent routedEvent, class System.Delegate handler, bool handledEventsToo) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.EventManager.RegisterClassHandler(System.Type,System.Windows.RoutedEvent,System.Delegate,System.Boolean)" />
<MemberSignature Language="VB.NET" Value="Public Shared Sub RegisterClassHandler (classType As Type, routedEvent As RoutedEvent, handler As Delegate, handledEventsToo As Boolean)" />
<MemberSignature Language="F#" Value="static member RegisterClassHandler : Type * System.Windows.RoutedEvent * Delegate * bool -> unit" Usage="System.Windows.EventManager.RegisterClassHandler (classType, routedEvent, handler, handledEventsToo)" />
<MemberSignature Language="C++ CLI" Value="public:
 static void RegisterClassHandler(Type ^ classType, System::Windows::RoutedEvent ^ routedEvent, Delegate ^ handler, bool handledEventsToo);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationCore</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<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="classType" Type="System.Type" />
<Parameter Name="routedEvent" Type="System.Windows.RoutedEvent" />
<Parameter Name="handler" Type="System.Delegate" />
<Parameter Name="handledEventsToo" Type="System.Boolean" />
</Parameters>
<Docs>
<param name="classType">The type of the class that is declaring class handling.</param>
<param name="routedEvent">The routed event identifier of the event to handle.</param>
<param name="handler">A reference to the class handler implementation.</param>
<param name="handledEventsToo">
<see langword="true" /> to invoke this class handler even if arguments of the routed event have been marked as handled; <see langword="false" /> to retain the default behavior of not invoking the handler on any marked-handled event.</param>
<summary>Registers a class handler for a particular routed event, with the option to handle events where event data is already marked handled.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Class handling is a feature that is available for routed events, including attached events that are implemented with routed event backing. A class handler is like a static handler that exists for all instances of the class. Because the handler is static, you cannot change instance properties directly with a class handler, but you can access instances through the `sender` parameter and/or the event data.
Class handlers are invoked before instance handlers. You can implement a class handler that has the behavior of marking the event as handled. Therefore, instance handlers for a class-handled event are not invoked unless the instance handlers register specifically for handled events.
Many of the WPF base element events provide class handling virtual methods. By overriding these methods in classes that inherit the base classes, you can implement class handling without calling <xref:System.Windows.EventManager.RegisterClassHandler%2A> in static constructors. These class handling methods typically exist for input events and have names that start with "On" and end with the name of the event being class handled.
For more information about class handling, see [Marking Routed Events as Handled, and Class Handling](/dotnet/framework/wpf/advanced/marking-routed-events-as-handled-and-class-handling).
Using this signature, class handlers can be registered to invoke upon handled events, by setting `handledEventsToo` set to `true`. Generally, you should do this only if there is a known handling issue you are trying to work around, such as input system handling from mouse or keyboard events.
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="RegisterRoutedEvent">
<MemberSignature Language="C#" Value="public static System.Windows.RoutedEvent RegisterRoutedEvent (string name, System.Windows.RoutingStrategy routingStrategy, Type handlerType, Type ownerType);" />
<MemberSignature Language="ILAsm" Value=".method public static hidebysig class System.Windows.RoutedEvent RegisterRoutedEvent(string name, valuetype System.Windows.RoutingStrategy routingStrategy, class System.Type handlerType, class System.Type ownerType) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.EventManager.RegisterRoutedEvent(System.String,System.Windows.RoutingStrategy,System.Type,System.Type)" />
<MemberSignature Language="VB.NET" Value="Public Shared Function RegisterRoutedEvent (name As String, routingStrategy As RoutingStrategy, handlerType As Type, ownerType As Type) As RoutedEvent" />
<MemberSignature Language="F#" Value="static member RegisterRoutedEvent : string * System.Windows.RoutingStrategy * Type * Type -> System.Windows.RoutedEvent" Usage="System.Windows.EventManager.RegisterRoutedEvent (name, routingStrategy, handlerType, ownerType)" />
<MemberSignature Language="C++ CLI" Value="public:
 static System::Windows::RoutedEvent ^ RegisterRoutedEvent(System::String ^ name, System::Windows::RoutingStrategy routingStrategy, Type ^ handlerType, Type ^ ownerType);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>PresentationCore</AssemblyName>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<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.RoutedEvent</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="name" Type="System.String" />
<Parameter Name="routingStrategy" Type="System.Windows.RoutingStrategy" />
<Parameter Name="handlerType" Type="System.Type" />
<Parameter Name="ownerType" Type="System.Type" />
</Parameters>
<Docs>
<param name="name">The name of the routed event. The name must be unique within the owner type and cannot be <see langword="null" /> or an empty string.</param>
<param name="routingStrategy">The routing strategy of the event as a value of the enumeration.</param>
<param name="handlerType">The type of the event handler. This must be a delegate type and cannot be <see langword="null" />.</param>
<param name="ownerType">The owner class type of the routed event. This cannot be <see langword="null" />.</param>
<summary>Registers a new routed event with the Windows Presentation Foundation (WPF) event system.</summary>
<returns>The identifier for the newly registered routed event. This identifier object can now be stored as a static field in a class and then used as a parameter for methods that attach handlers to the event. The routed event identifier is also used for other event system APIs.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Use the return value of this method to create the static declaration for a unique <xref:System.Windows.RoutedEvent> identifier field. This field should be stored within the owner type.
There are a considerable number of conventions and best practices associated with how routed events should be named, registered, and exposed in a class. For more information, see [Routed Events Overview](/dotnet/framework/wpf/advanced/routed-events-overview).
]]></format>
</remarks>
</Docs>
</Member>
</Members>
</Type>