c# - Handler for Custom Attached Event -
I am using a custom attachment event that I have created and I am trying to add a handler to this event
Public partial square main window: window {public main window ()} {initial timeliness}; } Private Zero dataGridTasks_Drop (Object Sender, RoutedEventArgs E) {}}
XAML Code Here
& lt; ListView util: DragDropHelper.Drop = "dataGridTasks_Drop" & gt;
I have this error in order in InitializeComponent
type 'System.String' can not be changed to type 'System.Windows.RoutedEventHandler' The object of
Anyone knows why I am getting this error? Thanks!
My Event Code
Public static read-only RoutedEvent DropEvent = EventManager.RegisterRoutedEvent ("Drop", RoutingStrategy.Bubble, typeof (DropEventArgs), typeof (DragDropHelper )); Public Static Zero AddDropHandler (Dependent Object D, Routing Avent Handler Handler) {UIElement uie = D as UIElement; If (UA! = Null) {U.A. Edhandsler (Dragafhalper. DoPevent, Handler); }} Public Static Zero Drawing Fraudler (Dependent Object D, Routing Avent Handler Handler) {UIElement uie = D as UIElement; If (UI! = Null) {U Remohandler (Dragraffhalper.DropEvent, Handler); }}
DropEventArgs code
class DropEventArgs: RoutedEventArgs {public object data {get; Private set; } Receive public INS index { Private set; } Public DropEventArgs (Rooted Event Routed Avent, Object Data, Int Index): Base (routedEvent) {Data = Data; Index = index; }}
After a few hours of sampling and checking my code, the problem is Was that the event's event really defined (Thanks Mihir and Dobbernal).
I made a mistake by providing the type of event instead of a handler type in the third argument of the RegisterRedEvent method.
The correct code is the following:
Public representative zero empty drop event handler (object sender, DropEventArgs e); Public static read-only RoutedEvent DropEvent = EventManager.RegisterRoutedEvent ("Drop", RoutingStrategy.Bubble, typeof (DropEventHandler), typeof (DragDropHelper));
The error message was misleading.
Comments
Post a Comment