Share via


NSView.Notifications.ObserveCreated Method

Definition

Overloads

Name Description
ObserveCreated(EventHandler<NSNotificationEventArgs>)

Strongly typed notification for the CreatedNotification constant.

ObserveCreated(NSObject, EventHandler<NSNotificationEventArgs>)

Strongly typed notification for the CreatedNotification constant.

ObserveCreated(EventHandler<NSNotificationEventArgs>)

Strongly typed notification for the CreatedNotification constant.

public static Foundation.NSObject ObserveCreated(EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveCreated : EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject

Parameters

handler
EventHandler<NSNotificationEventArgs>

The handler that responds to the notification when it occurs.

Returns

Token object that can be used to stop receiving notifications by either disposing it or passing it to RemoveObservers(IEnumerable<NSObject>).

Remarks

This method can be used to subscribe to CreatedNotification notifications.

// Listen to all notifications posted for any object
var token = NSView.Notifications.ObserveCreated ((notification) => {
  Console.WriteLine ("Observed CreatedNotification!");
};

// Stop listening for notifications
token.Dispose ();

Applies to

ObserveCreated(NSObject, EventHandler<NSNotificationEventArgs>)

Strongly typed notification for the CreatedNotification constant.

public static Foundation.NSObject ObserveCreated(Foundation.NSObject objectToObserve, EventHandler<Foundation.NSNotificationEventArgs> handler);
static member ObserveCreated : Foundation.NSObject * EventHandler<Foundation.NSNotificationEventArgs> -> Foundation.NSObject

Parameters

objectToObserve
NSObject

The specific object to observe.

handler
EventHandler<NSNotificationEventArgs>

The handler that responds to the notification when it occurs.

Returns

Token object that can be used to stop receiving notifications by either disposing it or passing it to RemoveObservers(IEnumerable<NSObject>).

Remarks

This method can be used to subscribe to CreatedNotification notifications.

// Listen to all notifications posted for a single object
var token = NSView.Notifications.ObserveCreated (objectToObserve, (notification) => {
  Console.WriteLine ($"Observed CreatedNotification for {nameof (objectToObserve)}!");
};

// Stop listening for notifications
token.Dispose ();

Applies to