そのため、キャンバスにドロップしたら、シェイプのコピーを作成しようとしています。私の EventHandlers は MainPage.xaml.cs にあります。次に、別のクラスを使用してドラッグ、ドロップなどを処理します。次に、形状クラスを拡張してコピーを作成し、それを返します。長方形がキャンバス上にある場合を除いて、すべてが機能しますが、イベントは機能しません。(xaml.cs のイベントを対象としていないため) これを修正するにはどうすればよいですか? ありがとう!
// In my drag/drop class I add the control
_cContainer.Children.Add(s.AsRectangle(_tContainer));
// In my extension of the shape class
public static Rectangle AsRectangle(this Shape s, Canvas c)
{
Rectangle r = new Rectangle() {
Fill = s.Fill,
Height = s.Height,
Width = s.Width
};
r.MouseLeftButtonDown += new MouseButtonEventHandler(Handle_MouseDown);
r.MouseMove += new MouseEventHandler(Handle_MouseMove);
r.MouseLeftButtonUp += new MouseButtonEventHandler(Handle_MouseUp);
Canvas.SetLeft(r, s.GetLeft() - c.Width);
Canvas.SetTop(r, s.GetTop());
return r;
}