DataObject::AddPastingHandler Method

Adds a Pasting event handler to a specified dependency object.

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

public:
static void AddPastingHandler(
	DependencyObject^ element, 
	DataObjectPastingEventHandler^ handler
)

Parameters

element
Type: System.Windows::DependencyObject

The dependency object (a UIElement or ContentElement) to which to add the event handler.

handler
Type: System.Windows::DataObjectPastingEventHandler

A delegate that references the handler method to add.

Use this event to inspect a data object before the data is pasted, and possibly to decide on an alternate course of action, such as:

  • Cancel the Paste - Cancel the entire paste operation by calling the CancelCommand method.

  • Select an Alternate Format - Change the selected paste format by specifying a new value for the FormatToApply property. The newly selected format must by supported by the data object to be pasted.

    NoteNote

    If the paste format is changed, ensure that the paste target supports the newly specified format.

  • Insert a New Format - If you determine that the paste data object does not support the desired format, update the data object to include a version of the data in the desired format. Custom data converters are often used as part of this process.

Changing the content of a paste data object (DataObject) does not change the data stored on the system Clipboard; any such changes will apply only to the data object associated with the associated paste command.

.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft