我必须调用DataObject.RemovePastingHandler()吗?

时间:2016-06-22 12:21:19

标签: c# wpf

我的程序有一个自定义用户控件,其中包含一个粘贴处理程序。是否有必要在任何时候调用DataObject.RemovePastingHandler方法,或者我的处理程序是否会被框架清理,例如当对象是Garbage Collected?

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

0 个答案:

没有答案