Currently, I have this implemented, where I have direct access to the class that I want to subscribe to, but what happens if I have a class that I don't have direct access to? i.e. An event that X triggers, with Y subscribing to it. Is it possible to do such without using a static event? Like if you have two windows and one thing happens on one, and you want something to trigger off of it on the second window.
Example:
Y (listens for event and DoSomething()) ---.
|----Event
X (triggers event when something changes) -'
Current code:
public static class MyEvents {
public delegate void FirstEventHandler();
}
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
SecondaryWindow secondWindow = new SecondaryWindow();
secondWindow.Show();
secondWindow.secondaryWindowEvent += new MyEvents.FirstEventHandler(callEvent);
}
protected void callEvent() {
MessageBox.Show("This is a MessageBox.");
}
}