i have following inheritance structure in wpf application:
in windowalpha
, there activated
event subscription:
public class windowalpha : window { public windowalpha() { activated += (x, y) => messagebox.show("started"); } }
the windowbravo class doesn't event:
public class windowbravo : windowalpha { }
in mainwindow, intend rid of subscription, tried this:
public partial class mainwindow : windowbravo { public mainwindow() { initializecomponent(); this.activated += (x, y) => { }; } }
also tried this:
public partial class mainwindow : windowbravo { public mainwindow() { initializecomponent(); base.activated += (x, y) => { }; } }
none of these usages affect the base of inheritance.
what can hide base activated event handling?
with anonymous delegates can't. way know of use actual method virtual.
public class windowalpha : window { public windowalpha() { activated += myonactivated; } protected virtual void myonactivated(object sender, eventargs args) { messagebox.show("started") } } public class windowbravo : windowalpha { } public partial class mainwindow : windowbravo { public mainwindow() { initializecomponent(); } protected override void myonactivated(object sender, eventargs args) { } }