WPF 自定义事件参数
自定义事件参数类:
/// <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);    
 
                    
                
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号