Export (0) Print
Expand All

RoutedEvent.AddOwner Method

Associates another owner type with the routed event represented by a RoutedEvent instance, and enables routing of the event and its handling.

Namespace:  System.Windows
Assembly:  PresentationCore (in PresentationCore.dll)

public RoutedEvent AddOwner(
	Type ownerType
)

Parameters

ownerType
Type: System.Type

The type where the routed event is added.

Return Value

Type: System.Windows.RoutedEvent
The identifier field for the event. This return value should be used to set a public static read-only field that will store the identifier for the representation of the routed event on the owning type. This field is typically defined with public access, because user code must reference the field in order to attach any instance handlers for the routed event when using the AddHandler utility method.

The owner type is used internally when resolving an event by name.

The following example adds the current class as another owner of an event defined in a different class. Here, AnotherEditContainer is the current class, and the EditStateChangedEvent RoutedEvent field is defined as a member of that class. The MyEditContainer class originally defined the event, registering it with the identically named EditStateChangedEvent identifier.

public static readonly RoutedEvent EditStateChangedEvent  = MyEditContainer.EditStateChangedEvent.AddOwner(typeof(AnotherEditContainer));

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft