編集

次の方法で共有


NSUndoManager.Notifications.ObserveWillCloseUndoGroup Method

Definition

Overloads

ObserveWillCloseUndoGroup(EventHandler<NSUndoManagerCloseUndoGroupEventArgs>)

Strongly typed notification for the WillCloseUndoGroupNotification constant.

ObserveWillCloseUndoGroup(NSObject, EventHandler<NSUndoManagerCloseUndoGroupEventArgs>)

Strongly typed notification for the WillCloseUndoGroupNotification constant.

ObserveWillCloseUndoGroup(EventHandler<NSUndoManagerCloseUndoGroupEventArgs>)

Strongly typed notification for the WillCloseUndoGroupNotification constant.

public static Foundation.NSObject ObserveWillCloseUndoGroup (EventHandler<Foundation.NSUndoManagerCloseUndoGroupEventArgs> handler);
static member ObserveWillCloseUndoGroup : EventHandler<Foundation.NSUndoManagerCloseUndoGroupEventArgs> -> Foundation.NSObject

Parameters

handler
EventHandler<NSUndoManagerCloseUndoGroupEventArgs>

Method to invoke when the notification is posted.

Returns

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

Remarks

The following example shows how developers can use this method in their code:

//
// Lambda style
//

// listening
notification = NSUndoManager.Notifications.ObserveWillCloseUndoGroup ((sender, args) => {
    /* Access strongly typed args */
    Console.WriteLine ("Notification: {0}", args.Notification);

    Console.WriteLine ("Discardable", args.Discardable);
});

// To stop listening:
notification.Dispose ();

//
//Method style
//
NSObject notification;
void Callback (object sender, Foundation.NSUndoManagerCloseUndoGroupEventArgs args)
{
    // Access strongly typed args
    Console.WriteLine ("Notification: {0}", args.Notification);

    Console.WriteLine ("Discardable", args.Discardable);
}

void Setup ()
{
    notification = NSUndoManager.Notifications.ObserveWillCloseUndoGroup (Callback);
}

void Teardown ()
{
    notification.Dispose ();
}

Applies to

ObserveWillCloseUndoGroup(NSObject, EventHandler<NSUndoManagerCloseUndoGroupEventArgs>)

Strongly typed notification for the WillCloseUndoGroupNotification constant.

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

Parameters

objectToObserve
NSObject

The object to observe.

handler
EventHandler<NSUndoManagerCloseUndoGroupEventArgs>

Method to invoke when the notification is posted.

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 for WillCloseUndoGroupNotification notifications.

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

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

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

Applies to