How to raise an attached event in wpf?
How can I 开发者_StackOverflow社区raise DataObject.Pasting event from my code?
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);
You need to call RaiseEvent on the appropriate UIElement, passing in a RoutedEventArgs with RoutedEvent set to DataObject.Pasting.
精彩评论