如何覆盖 CustomButton class 中的 TouchUpInside 事件?

How to override TouchUpInside event in CustomButton class?

我有一个自定义按钮:

public class CustomButton : UIButton
{
    public void HandleTouchUpInside(object sender, EventArgs ea)
    {
        Console.Write("test tap"); 
    }
}

所以我想在此 class 中覆盖 TouchUpInside 事件...该怎么做?

它对你有用吗?

public class CustomButton : UIButton
{
    public CustomButton()
    {
        TouchUpInside += HandleTouchUpInside;

        // or new EventHandler(HandleTouchUpInside)
        // if Xamarin compiler/runtime doesn't allow such shorter code
    }

    public void HandleTouchUpInside(object sender, EventArgs e)
    {
        Console.Write("test tap"); 
    }
}