Bi-directional communication between different windows/views
2-way messaging
class SelectCustomer
{
public object RequestToken{ get; set; }
}class CustomerSelected
{
public object RequestToken{ get; set; }
public IEnumerable<Customer> Selection{ get; set; }
}class OrderViewModel
{
IMessageBroker broker
object requestToken = null;
public OrderViewModel( IMessageBroker broker )
{
this.broker = broker;
this.broker.Subscribe<CustomerSelected>( this, ( s, m ) =>
{
if( m.RequestToken == this.requestToken )
{
//do something with the selection
}
} );
}
void Select()
{
this.requestToken = new object();
this.broker.Broadcast( this, new SelectCustomer() );
}
}Message callback
Dedicated services
PreviousGet the view of a given view modelNextHandle the busy status during async/long running operations
Last updated