In my application I have simple EventHandler (in my ViewModel) defined as this :
public event EventHandler FavouriteChangedEvent;
Then when I need, I fire the event with this
FavouriteChangedEvent(this, null);
Everything is working as expected, however in my app, there are clickable links, which opens webbrowser (as separate app). When you go back to the application, then when I try to run FavouriteChangedEvent(this, null);
it ends with NullPointerException (From debugging it is beacause FavouriteChangedEvent
is really null).
Why is that?
I find this on the internet and used it
public delegate void EventHandler(object sender, string myValue);
public event EventHandler FavouriteChangedEvent = delegate { };
But it does not help much. The application does not fall, but in my View class, I have this line in constructor _dataContext.FavouriteChangedEvent += _dataContext_FavouriteChangedEvent;
After go out and back to the app, this event is not triggered anymore.