简体   繁体   中英

Creating custom event in windows phone

I have such usecase:

In my application some instances need to fire event, that they have been changes. But, I dont want to keep references to instances that need to be changed, so I would like to send event and somehow listen it in some places, but how to do it in C# in windows phone?

You're looking for the EventAggregator. There are a few toolkits that you can build upon like GalaSoft's MVVM Light and Caliburn Micro . You can find a good example of this at http://www.mindscapehq.com/blog/index.php/2012/02/01/caliburn-micro-part-4-the-event-aggregator/ .

The basic gist of it is to inject an EventAggregator into your ViewModel. This ViewModel would Publish an event. Other ViewModels would subscribe to this event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM