#585 – 隧道事件沿逻辑树从上至下传递(Tunneling Events Propagate Down the Logical Tree)
来源:互联网 发布:java开发大牛博客 编辑:程序博客网 时间:2024/06/06 14:00
在WPF中,冒泡事件从引发事件的控件开始,沿着逻辑树或者可视树向上传递。与之相反,隧道事件则是从层次结构的顶点出发,由上至下传递直到传递到引发事件的控件。
下面的代码中我们给各层的控件都注册了PreviewKeyDown 事件,然后在最下面的TextBox中按键输入。
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" xmlns:loc="clr-namespace:WpfApplication11" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" x:Class="WpfApplication11.MainWindow" x:Name="Window" Title="Routed Events" Width="400" PreviewKeyDown="winMain_PreviewKeyDown"> <StackPanel Name="spMain" Orientation="Vertical" PreviewKeyDown="spMain_PreviewKeyDown"> <Label Content="Some good movies:"/> <StackPanel Orientation="Horizontal" Margin="10" PreviewKeyDown="spLawrence_PreviewKeyDown"> <Label Content="Lawrence of Arabia" FontWeight="Bold"/> <Label Content="David Lean"/> <Button Content="Like" Padding="8,0"/> <TextBox Width="75" Margin="5,2" PreviewKeyDown="tbLawrence_PreviewKeyDown"/> </StackPanel> </StackPanel></Window>
显示结果:
原文地址:https://wpf.2000things.com/2012/06/21/585-tunneling-events-propagate-down-the-logical-tree/
0 0
- #585 – 隧道事件沿逻辑树从上至下传递(Tunneling Events Propagate Down the Logical Tree)
- #108 – The Logical Tree(逻辑树)
- #586 – 冒泡事件和隧道事件通常是成对出现(Bubbling and Tunneling Events Are Typically Paired)
- #131 – Dependency Properties Inherit Values from Higher Up in the Logical Tree(逻辑树中元素的依赖属性可从其上层元素继承)
- Understanding the Visual Tree and Logical Tree in WPF
- #636 – 持续按住按键会多次触发键盘事件(Keyboard Events that Fire When A Key Is Held Down)
- events 事件
- 点对点隧道协议PPTP(Point-to-Point Tunneling Protocol)
- Tunneling
- Tunneling
- Fortran 逻辑变量(LOGICAL)
- 逻辑模型 - Logical Data Model
- travel the binary tree by level( from top to down)
- The logical standby database
- #309 – 键盘焦点和逻辑焦点(Keyboard Focus vs. Logical Focus)
- Binary Tree Upside Down
- Binary Tree Upside Down
- Binary Tree Upside Down
- 【后台学习】MyEclipse+Maven+Tomcat的安装和配置
- PHP 含换行符的字符串复制给js变量的方法
- eclipse插件egit操作
- 图像拼接-硬拼接
- 【Leetcode】9. Palindrome Number
- #585 – 隧道事件沿逻辑树从上至下传递(Tunneling Events Propagate Down the Logical Tree)
- iOS语音通话(语音对讲)
- Android开发中出现的错误集
- 利用Visua Studio Code编辑与调试Python-Opencv代码
- 干货:Unity游戏开发图片纹理压缩方案
- numa总结
- 关联容器:永远让比较函数对相等的值返回false
- SpringMVC源码总结(十一)mvc:interceptors拦截器介绍
- ipsec VPN 原理