2012-03-22 9 views

答えて

0

プリズムは、MyEventクラスからSomeMethodにプロパティを渡しません。それはpayloadsをDTOとして渡します:

public class MyEvent: CompositePresentationEvent<MyEventArgs> {} 

public class MyEventArgs { int MyIntValue; } 

public class Subscriber 
{ 
    public Subscriber 
    { 
    eventAggregator.GetEvent<MyEvent>().Subscribe(SomeMethod); 
    } 

    public void SomeMethod(MyEventArgs e) 
    { 
    MessageBox.Show(e.MyIntValue); 
    } 
} 

public class Publisher 
{ 
    public void SendMinusOne() 
    { 
    var args = new MyEventArgs() { MyIntValue = -1 }; 
    eventAggregator.GetEvent<MyEvent>().Publish(args); 
    } 
} 
関連する問題