public void RoleChangedHandler(object sender, RoutedEventArgs e) { RootNet rootNet = e.OriginalSource as RootNet; if (rootNet != null) { MessageBox.Show(rootNet.Role); } }
private void button_Click(object sender, RoutedEventArgs e) { RootNet root = new RootNet() { Role = "C#" }; RoutedEventArgs arg = new RoutedEventArgs(RootNet.RoleChanged, root); button.RaiseEvent(arg); }
public Window2() { InitializeComponent(); RootNet.AddRoleChangedHandler(this.gridMain, RoleChangedHandler); }