C# 我必须调用DataObject.RemovePastingHandler()吗?
我的程序有一个自定义用户控件,其中包括粘贴处理程序。是否需要在任何时候调用C# 我必须调用DataObject.RemovePastingHandler()吗?,c#,wpf,C#,Wpf,我的程序有一个自定义用户控件,其中包括粘贴处理程序。是否需要在任何时候调用DataObject.RemovePastingHandler方法,或者我的处理程序是否会被框架清除,例如,当对象被垃圾收集时 public class MyUserControl : UserControl { public MyUserControl() : base() { // Other construction & initialisation code
DataObject.RemovePastingHandler
方法,或者我的处理程序是否会被框架清除,例如,当对象被垃圾收集时
public class MyUserControl : UserControl
{
public MyUserControl()
: base()
{
// Other construction & initialisation code goes here.
// Add the pasting handler.
DataObject.AddPastingHandler(this, PastingHandler);
// Do I need to call the complimentary method anywhere?
// DataObject.RemovePastingHandler(this, PastingHandler);
}
private static void PastingHandler(object sender, DataObjectPastingEventArgs e)
{
// Do magic to handle the paste request.
}
}