自定义事件参数类:

/// <summary>
///
自定义事件参数类
/// </summary>
public class MyRoutedEventArge:RoutedEventArgs
{}

自定义路由事件:

//自定义事件委托
public delegate void MyRoutedEventHandler(object sender ,MyRoutedEventArge e);

//路由事件
public static readonly RoutedEvent MyRoutedEvent = EventManager.RegisterRoutedEvent(
   "MyRouted", RoutingStrategy.Bubble, typeof(MyRoutedEventHandler), typeof(UserControl1));

public event MyRoutedEventHandler MyRouted
{
    add { AddHandler(MyRoutedEvent,value); }
    remove { RemoveHandler(MyRoutedEvent,value); }
}

 

引发事件:

 

MyRoutedEventArge args = new MyRoutedEventArge();
args.RoutedEvent = MyRoutedEvent;
RaiseEvent(args);

相关文章:

  • 2022-12-29
  • 2021-09-26
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2022-01-24
猜你喜欢
  • 2022-01-22
  • 2021-10-19
  • 2021-09-05
  • 2021-09-02
相关资源
相似解决方案