I’m new to WP7 and coming from iPhone development. On iPhone I’m used to use NSNotificationCenter to notify my program of something. NSNotificationCenter is build-in the framework out of the box. Is there something similar in WP7? I stumbled uppon MVVM-Light Toolkit but I’m not sure how to use it correctly.
What I want to do:
- Register to an Notification-Id and do something when Notification-Id is received
- Send Notification with Notification-Id and a context (object to pass to observers)
- Everyone who registers to the same Notification-Id will be notified
So something like: Registering
NotificationCenter.Default.register(receiver, notification-id, delegate);
Sending:
NotificationCenter.Default.send(notification-id, context);
Example for Registering:
NotificationCenter.Default.register(this, NotifyEnum.SayHello, m => Console.WriteLine("hello world with context: " + m.Context));
Sending …
NotificationCenter.Default.send(NotifyEnum.SayHello, "stackoverflow context");
Here is how to do with the MVVM Light Toolkit:
Registering:
Sending: