WPF 4.5 EventAggregator in App class

Jul 7, 2015 at 6:28 AM

i need to use eventaggregator interface in my WPF App class.
the reason for this, because i might have general exception, which i can handle in the application DispatcherUnhandledException event
depending on the exception type i might have to call an event to display the proper UI to the user.

for all over my viewmodels i use the eventaggregator import through constructor import, but App doesn't have constructor allowing me specifying parameter there. so i try with field import, but it is always null.
most probably i need some export, but none of the export variations work. i tried already with many configurations.

can you please help me,
Jul 7, 2015 at 1:23 PM
I would handle this by leveraging the fact that the bootstrapper has a public Container property on it. After calling Bootstrapper.Run in your App code behind, grab the Container ref and use it to inject (programmatically) an IEventAggregator ref into your App class to use when the unhandled exception event (or others) fire.
Marked as answer by pillesoft on 7/7/2015 at 7:55 AM
Jul 7, 2015 at 2:55 PM
thanks Brian,

this works!