I have read through a lot of articles to resolve this problem, but I can't get this to work.
The Situation: I have a WPF MainWindow where I am loading UserControls into it. The Mainwindow should listen to an EventHandler in a Class called Navigation. The Event will be fired upon certain changes in the UserControls.
So far I can confirm that the UserControls can fire the Event, but the MainWindow does not pickup the Throw.
Navigation Class:
public class Navigation
{
public delegate void EventHandler(object sender, EventArgs args);
public event EventHandler ThrowEvent = delegate { };
public void NavigationUpdateEvent()
{
ThrowEvent(this, new EventArgs());
}
}
UserControl:
public delegate void EventHandler(object sender, EventArgs args);
public event EventHandler ThrowEvent = delegate { };
Navigation myNavigation = new Navigation();
public myUserControl()
{
InitializeComponent();
}
private void CheckBox_Click(object sender, RoutedEventArgs e)
{
if (cbCheckBox.IsChecked.Value)
{
UMENavigation.NavigationUpdateEvent();
}
}
The MainWindow:
private void DoSomething()
{
MessageBox.Show("It worked!");
}
private Navigation _Thrower;
public MainWindow()
{
InitializeComponent();
_Thrower = new Navigation();
_Thrower.ThrowEvent += (sender, args) => { DoSomething(); };
}
However, the _Thrower never picks up the Fired Event..
Any help is greatly appreciated! This is starting to hurt :)
Greetings, Tom