开发者

Handling Page Size Change Events with Prism and Event Aggregator

I need to capture when the Page_SizeChanged event fires in a WPF Browser application and publish the event through the Pr开发者_运维问答ism 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜