WPF基础之路由事件

it2025-04-22  16

 一、路由事件的声明、注册和属性包装Border

class ButtonBase:ContentControl { //1.声明 public static readonly RoutedEvent ClickEvent; //2.注册 static ButtonBase() { ButtonBase.ClickEvent = EventManager.RegisterRoutedEvent("Click",RoutingStrategy.Bubble, typeof(RoutedEventHandler),typeof(ButtonBase)); } //3.属性包装器 public event RoutedEventHandler Click { add { base.AddHandler(ButtonBase.ClickEvent,value); } remove { base.RemoveHandler(ButtonBase.ClickEvent, value); } } }

 二、冒泡路由事件

 三、附加事件

 四、隧道路由事件

     隧道路由事件的工作方式和冒泡路事件相同,但方向相反。隧道路由事件易于识别,他们都是以Preview开头。而且WPF成对的定义冒泡路由事件和隧道路由事件。

 五、WPF主要事件分类

 

转载于:https://www.cnblogs.com/lovezhangyu/p/10189058.html

相关资源:各显卡算力对照表!
最新回复(0)