Question

I need to capture when the Page_SizeChanged event fires in a WPF Browser application and publish the event through the Prism EventAggregator. Since the page I am interested in happens to be the Shell page, I don't have a ViewModel attached where I can access the eventaggregator.

Was it helpful?

Solution

In your bootstrapper (i.e. UnityBootstrapper derived class) where you initialize your shell, IEventAggragator is registered with the Unity container during the call to the base class ConfigureContainer method. Therefore if you override ConfigureContainer, you can resolve the event aggregator:

protected override void ConfigureContainer()
{
    base.ConfigureContainer();

    IEventAggregator eventService = Container.Resolve<IEventAggregator>();
}

At this point you could set a property on your shell\viewmodel with the event aggregator instance, or use a service locator type pattern for example. That's up to you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top