Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 我必须调用DataObject.RemovePastingHandler()吗?_C#_Wpf - Fatal编程技术网

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.
    }
}