Hi,
I subscribe to an Event
inside a class
. Such as
MainStation mainStation = StationFactory.GetMainStation();
mainStation.FrequencyChanged += new EventArgs(MainStation_FrequencyChanged);
My MainStation
class raises the event on some condition by just calling the event FrequencyChanged()
The Problem
Now I have a scenario where I must instantiate SubStation
from MainStation
which is also a subclass of MainStation
with some additional features and FrequencyChanged
event must be subscribed as the MainStation
subscrbed. Consider the code noted below:
public class MainStation
{
public event EventHandler FrequencyChanged;
public static SubStation CreateSubStation()
{
SubStation subStation = new SubStation();
//here I want to pass/bubble FrequencyChanged event to SubStation
subStation.FrequencyChanged = FrequencyChanged; //THIS IS WRONG
}
}
Bottom Line
I want to fire an event that a class subscribes from another class, also bubble up events
Update
StationFactory
creates MainStation
and the FrequencyChanged
event in MainStation
instance is set as defined in the first code block.