作成したカスタム添付イベントを使用しており、このイベントにハンドラーを追加しようとしています
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void dataGridTasks_Drop(object sender, RoutedEventArgs e)
{
}
}
ここに XAML コード
<ListView util:DragDropHelper.Drop="dataGridTasks_Drop">
InitializeComponent で実行時にこのエラーが発生しました
'System.String' 型のオブジェクトは、'System.Windows.RoutedEventHandler' 型に変換できません。
このエラーが発生する理由を知っている人はいますか? ありがとう !
ここに私のイベントコード
public static readonly RoutedEvent DropEvent = EventManager.RegisterRoutedEvent(
"Drop", RoutingStrategy.Bubble, typeof(DropEventArgs), typeof(DragDropHelper));
public static void AddDropHandler(DependencyObject d, RoutedEventHandler handler)
{
UIElement uie = d as UIElement;
if (uie != null)
{
uie.AddHandler(DragDropHelper.DropEvent, handler);
}
}
public static void RemoveDropHandler(DependencyObject d, RoutedEventHandler handler)
{
UIElement uie = d as UIElement;
if (uie != null)
{
uie.RemoveHandler(DragDropHelper.DropEvent, handler);
}
}
DropEventArgs コード
class DropEventArgs : RoutedEventArgs
{
public object Data { get; private set; }
public int Index { get; private set; }
public DropEventArgs(RoutedEvent routedEvent, object data, int index)
: base(routedEvent)
{
Data = data;
Index = index;
}
}