Subscribe to multiple Events

Nov 30, 2010 at 9:37 PM

When a ViewModel subscribes to any events it needs to inherit from IHandle<Event Parameter Object>

Suppose if the ViewModel needs to subscribe to multiple events the only way I see is inherit from Ihandle interface multiple times and use different paramter objects like below

 

    public class DisplayFollowupsModel : PropertyChangedBase, IDisplayFollowupsModel, IHandle<QuoteFollowupSearchCriteria>, IHandle<AgentSearchCriteria>
    {
        public DisplayFollowupsModel()
        {
            EventAggregatorContainer.EventAggregator.Subscribe(this);
        }

        public void Handle(QuoteFollowupSearchCriteria message)
        {
            //Do what you want
        }

        public void Handle(AgentSearchCriteria message)
        {
            //Do what you want
        }
    }
Can anyone tell me if this is the correct way to do? We are new to caliburn implementation, so please excuse if this is a basic question. I could not find this example anywhere.

Coordinator
Nov 30, 2010 at 9:40 PM

You are correct.

Nov 30, 2010 at 9:44 PM

Thank you for the prompt response