views:

47

answers:

2

How can I raise DataObject.Pasting event from my code?

+1  A: 

You need to call RaiseEvent on the appropriate UIElement, passing in a RoutedEventArgs with RoutedEvent set to DataObject.Pasting.

Phil Devaney
thanks but i can accept only one correct answer.
Rohit
+2  A: 

You can raise any event on any UIElement using the RaiseEvent() method. Just create the appropriate event args for the handler and pass to RaiseEvent().

var args = new DataObjectPastingEventArgs(dataObject, isDragDrop, formatToApply)
{
    Source = this,
    RoutedEvent = DataObject.PastingEvent //set the event here
};
element.RaiseEvent(args);
Jeff M