My approach, for what it's worth, would be to do something like this. Using Prism.Events
, declare an event. In the following example the event's payload is a bool
but you can use any object.
public class DatabaseServiceIsSavedEvent : PubSubEvent<bool>
{
}
In the
class
that wishes to publish the event, have an instance of
IEventAggregator aggregator
then, when you want to raise the event, you can publish the event like this.
aggregator.GetEvent<DatabaseServiceIsSavedEvent>().Publish(true);
In this case the payload is a
bool
set to
true
.
In the constructor of the
class
that you wish to receive the event, you subscribe to the event, passing in the method that you wish to be called when the event is raised. For example.
aggregator.GetEvent<DatabaseServiceIsSavedEvent>()
.Subscribe(OnIsSavedEvent);
The
OnIsSavedEvent
method is something like this.
public void OnIsSavedEvent(bool isSaved)
{
IsModified = !isSaved;
}