(5) C# 路由事件
一、路由事件
1.定义、注册、封装路由
路由事件和依赖属性的定义类似
public abstract class ButtonBase : ContentControl { public static readonly RoutedEvent ClickEvent; static ButtonBase() { ClickEvent = EventManager.RegisterRoutedEvent("Click", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ButtonBase)); } public event RoutedEventHandler Click { add { AddHandler(ClickEvent, value); } remove { RemoveHandler(ClickEvent, value); } } }
路由事件封装成普通都能访问的事件 add 和remove
2.共享路由