RoutedEvent.AddOwner(Type) Método

Definición

Asocia otro tipo de propietario con el evento enrutado representado por una instancia de RoutedEvent y habilita enrutamiento del evento y su control.Associates another owner type with the routed event represented by a RoutedEvent instance, and enables routing of the event and its handling.

public:
 System::Windows::RoutedEvent ^ AddOwner(Type ^ ownerType);
public System.Windows.RoutedEvent AddOwner (Type ownerType);
member this.AddOwner : Type -> System.Windows.RoutedEvent
Public Function AddOwner (ownerType As Type) As RoutedEvent

Parámetros

ownerType
Type

Tipo al que se agrega el evento enrutado.The type where the routed event is added.

Devoluciones

Campo del identificador del evento.The identifier field for the event. Este valor devuelto se debe usar para establecer un campo de sólo lectura estático público que almacenará el identificador de la representación del evento enrutado en el tipo propietario.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. Este campo se define normalmente con acceso público, porque el código de usuario debe hacer referencia al campo para adjuntar cualquier controlador de la instancia para el evento enrutado al utilizar el método de utilidad AddHandler(RoutedEvent, Delegate, Boolean).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(RoutedEvent, Delegate, Boolean) utility method.

Ejemplos

En el ejemplo siguiente se agrega la clase actual como otro propietario de un evento definido en una clase diferente.The following example adds the current class as another owner of an event defined in a different class. Aquí, AnotherEditContainer es la clase actual y el EditStateChangedEvent RoutedEvent campo se define como un miembro de esa clase.Here, AnotherEditContainer is the current class, and the EditStateChangedEvent RoutedEvent field is defined as a member of that class. La MyEditContainer clase definía originalmente el evento y lo registra con el identificador con el mismo EditStateChangedEvent nombre.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));
Public Shared ReadOnly EditStateChangedEvent As RoutedEvent = MyEditContainer.EditStateChangedEvent.AddOwner(GetType(AnotherEditContainer))

Comentarios

El tipo de propietario se usa internamente al resolver un evento por nombre.The owner type is used internally when resolving an event by name.

Se aplica a