When should you override OnEvent as opposed to subscribing to the event when inheritting

后端 未结 7 1981
梦谈多话
梦谈多话 2020-12-11 01:33

When should one do the following?

class Foo : Control
{
    protected override void OnClick(EventArgs e)
    {
        // new code here
    }
}
7条回答
  •  甜味超标
    2020-12-11 02:33

    It is worth noting that there are some corner cases where it only works with handlers and not with OnEvent overrides. One such example-

    Why style is not applied when I'm removing StartupUri in WPF?

提交回复
热议问题