#131 – Dependency Properties Inherit Values from Higher Up in the Logical Tree(逻辑树中元素的依赖属性可从其上层元素继承)
来源:互联网 发布:php和seo哪个好 编辑:程序博客网 时间:2024/05/19 08:38
原文地址:https://wpf.2000things.com/2010/11/20/131-dependency-properties-inherit-values-from-higher-up-in-the-logical-tree/
依赖属性的值可以有很多不同的来源,比较常见的一种是从其逻辑树的更上层继承而来。
这意味着当我们在XAML或者代码中设置一个依赖属性的值的时候,这个值会沿着逻辑树向下传递给其他同样拥有这个依赖属性的元素。
下面是个例子。有若干个控件的FontStyle 属性值继承自最高级的Window 元素。
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:m="clr-namespace:PersonLib;assembly=PersonLib" Title="MainWindow" Height="350" Width="525" FontStyle="Italic"> <StackPanel Orientation="Vertical"> <Button Content="Run" Height="23" Width="75" /> <Button Content="Skip" Height="23" Width="75" /> <StackPanel Orientation="Horizontal"> <Label Content="Inside 2nd StackPanel"/> <Label Content="I do my own FontStyle" FontStyle="Normal"/> </StackPanel> </StackPanel></Window>
这是上面代码显示的窗口:
如果某个元素中的依赖属性被明确的赋值了,那么它就会忽略继承来的值而使用自己赋值的值。
0 0
- #131 – Dependency Properties Inherit Values from Higher Up in the Logical Tree(逻辑树中元素的依赖属性可从其上层元素继承)
- #116 – Dependency Property Values Are Stored in the DependencyObject(依赖属性存储在DependencyObject中)
- #151 – Dependency Properties Remember Non-Coerced Values(依赖属性强制转换之前的值会被记住)
- #108 – The Logical Tree(逻辑树)
- #585 – 隧道事件沿逻辑树从上至下传递(Tunneling Events Propagate Down the Logical Tree)
- #114 – How Dependency Properties Are Implemented(依赖属性是如何应用的)
- 依赖属性(Dependency Properties)基础
- CLIPS-logical条件元素-事实依赖
- 依赖属性(Dependency Properties)进阶(一)
- 依赖属性(Dependency Properties)进阶(二)
- 从List中移除指定 List 中包含的其所有元素(可选操作)。
- Action中元素的可访问属性的设置
- css中元素常用的可继承和不可继承元素的属性
- javascript中原型继承(prototype inherit)的理解
- #154 – Reusing an Existing Dependency Property in Your Class(重用依赖属性)
- CSS中inherit指定继承的使用方法
- CSS中inherit指定继承的使用方法
- Understanding the Visual Tree and Logical Tree in WPF
- OSCAR的奇难杂症
- Activity设置Theme为Dialog样式
- 隐藏导航栏底部横线
- iOS开发中调用网址、拨打电话、发送短信、发送邮件
- Android开发从初级到高级学习路线
- #131 – Dependency Properties Inherit Values from Higher Up in the Logical Tree(逻辑树中元素的依赖属性可从其上层元素继承)
- /proc 文件系统的学习
- 那些年我们刷过的算法题---滑动窗口练习题
- CSS Modules 用法教程
- f_sync解决fatfs文件掉电数据丢失问题
- 通过List.apply方法构造List的背后逻辑
- 专题四-1006-典型Kruskal算法应用
- Android振动器(Vibrator)系统详解
- 前后端数据交互方法