- 浏览: 399032 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (309)
- xaml C# wpf (0)
- scala java inner clas (1)
- Tools UML Eclipse UML2 (1)
- Timer .NET Framework (1)
- perl (6)
- python function paramter (1)
- Python Docstring (1)
- Python how to compare types (1)
- Python (8)
- java (5)
- C# (76)
- C# WPF (0)
- p4 (0)
- WPF (46)
- .net (6)
- xaml (1)
- javascript (40)
- windows (10)
- scala (4)
- winform (1)
- c++ (48)
- tools (12)
- cmd (1)
- os (0)
- CI (0)
- shell (0)
- C (2)
- haskell (49)
- functional (1)
- tool (1)
- gnu (1)
- linux (1)
- kaskell (0)
- svn (0)
- wcf (3)
- android (1)
最新评论
As discussed in my previous post, - wpf - Dependency Property Value Precedence, and the original article on Dependency Property Value Precedence; There exists situation where the value of some DependencyProperty is determined by at runtime according to the list of precedence. e..g the background of a TextBlock in a ToolWindow is null, but because the ToolWindow has background property overriden, you ends up saying the TextBlock to have the background of the ToolWindow.
Below shows the method that return an effective value of DependencyProperty identified by the propertyName parameter.
/// <summary> /// Get the effective property from the Dependency Property and the Metadata system /// </summary> /// <typeparam name="T"></typeparam> /// <param name="propertyName"></param> /// <param name="element"></param> /// <returns></returns> public static T GetEffectiveDependencyPropertyValue<T>(string propertyName, FrameworkElement element) { if (element == null) throw new ArgumentNullException("element"); if (propertyName == null) throw new ArgumentNullException("propertyName"); var visual = (DependencyObject)element; while (visual != null) { var propertyDescriptor = DependencyPropertyDescriptor.FromName(propertyName, visual.GetType(), visual.GetType(), true); var propertyValue = propertyDescriptor.GetValue(visual); if (propertyValue != null) { return (T)propertyValue; } visual = LogicalTreeHelper.GetParent(visual); } return default(T); }
To use it, you just do
FrameworkElement visua = ... var background = GetEffectiveDependencyPropertyValue<Brush>("Background", visual);
发表评论
-
wpf - example to enhance ComboBox for AutoComplete
2014-09-19 15:56 1975first let’s see an example ... -
WPF – Virtualization – VirutalizationStackPanel and ItemsPanelTemplate
2013-08-05 21:55 1407Topic: WPF – Virtualization – ... -
wpf - BehaviorBase and one use examples
2013-06-18 18:41 1309Behavior is something that we ... -
WPF - Setting foreground color of Entire window
2013-06-13 16:00 1914You might as well as I would s ... -
WPF - Enhanced TabControl - TabControlEx aka Prerendering TabControl
2013-06-13 13:12 5327As an opening word, let's che ... -
wpf - ControlTemplate and AddLogicChild/RemoveLogicalChild
2013-06-10 15:42 1184Recently I was trying to debug ... -
wpf - default implicit style
2013-05-10 10:24 793We know that if you left out ... -
wpf - Style setter on the attached property
2013-05-08 14:54 2850I believe that you are familia ... -
wpf - specify enum values in xaml
2013-05-08 11:31 3580Many a situation you find tha ... -
wpf - IG xamDataGrid bind to XmlDataProvider with Xml Island
2012-12-18 14:28 1284Sometimes you may bind to some ... -
wpf - translate winform button/mouse event to wpf events
2012-12-12 17:37 2160It is common that we sometimes ... -
wpf - Freezable and its meaning
2012-09-27 12:38 0This article is based on the di ... -
wpf - Customize the grid lines for original wpf Grid control
2012-09-27 12:01 1456The System.WIndows.Controls.Gri ... -
c# - Convert from System.Drawing.Image to System.WIndows.Media.ImageSource
2012-09-25 14:27 7415In Previous discussion, we have ... -
wpf - Default(Theme) style and its DefaultStyleKey
2012-08-28 17:54 1384As dicsused in the subsection o ... -
wpf - Dependency Property Value Precedence
2012-08-28 18:56 879A dependency property to an Dep ... -
wpf - WPF TemplateBinding vs RelativeSource TemplatedParent
2012-08-28 14:20 3709This is a post that summarizes ... -
wpf - ICutomTypeDescriptor , PropertyDescriptor and its use in PropertyGrid
2012-08-28 14:04 3578The type ICustomTypeDe ... -
wpf - tips to convert UI controls in WPF/Silverlight/Winforms into a Bitmap
2012-08-27 17:44 974In previous discussion, we have ... -
wpf - input binding examples
2012-08-27 11:47 1215Input binding is the mechanism ...
相关推荐
gong-wpf-dragdrop, GongSolutions.WPF.DragDrop 库是WPF的拖动'n'拖放框架 简介GongSolutions.WPF.DragDrop 库是一个易于使用的拖拉'n'拖放框架。特性使用 MVVM: 拖放逻辑可以放在ViewModel中。 代码不需要放在in中...
在这个名为"WPF-ControlBase-master.zip"的压缩包中,我们可以推测它包含了一个基于WPF的控制库项目,可能是一个开源或者个人开发的项目,用于提供自定义的WPF控件。这些控件可能是对标准WPF控件的扩展或增强,也...
C#开发WPF-Silverlight动画及游戏系列教程-深蓝色右手 C#开发WPF-Silverlight动画及游戏系列教程-深蓝色右手 C#开发WPF-Silverlight动画及游戏系列教程-深蓝色右手
WPF的基本空间历程,使用.net core3.0.1版本
通过深入研究WPF-Diagram-Designer的源代码(如WPF-Diagram-Designer-master文件夹中的内容),开发者不仅可以学习到如何在WPF中构建复杂的图形界面,还可以了解到图形编辑器的设计原理和实现细节,对于提升图形应用...
DependencyProperty是WPF中的一个重要概念,它是实现数据绑定、属性更改通知和样式触发的关键机制。在这个“C# WPF DependencyProperty程序”中,我们可以深入理解这一特性。 DependencyProperty允许控件或类的属性...
WPF 依赖属性 DependencyProperty C# WPF 依赖属性 DependencyProperty C# WPF 依赖属性 DependencyProperty C# WPF 依赖属性 DependencyProperty C#
“wpf---StatusBar”这个标题表明我们将探讨的是WPF(Windows Presentation Foundation)框架中的StatusBar组件。WPF是.NET Framework的一部分,用于构建桌面应用程序,它提供了丰富的用户界面(UI)功能。StatusBar...
**WPF - 强大的图表技术** Windows Presentation Foundation (WPF) 是Microsoft开发的一个用于构建桌面应用程序的框架,它提供了丰富的图形系统,包括对2D和3D图形的强大支持。在WPF中,开发人员可以利用各种图表...
在这个“wpf-datagrid-access DB”主题中,我们将深入探讨如何利用WPF Datagrid与Microsoft Access数据库进行交互,实现数据的读取、更新和保存。 1. **WPF Datagrid简介** - Datagrid是WPF中的一个数据展示控件,...
C#开发WPF-Silverlight动画及游戏系列教程-深蓝色右手 C#开发WPF-Silverlight动画及游戏系列教程-深蓝色右手 C#开发WPF-Silverlight动画及游戏系列教程-深蓝色右手
超酷WPF数据可视化,全套源程序,非常适合做数据可视化的程序员使用,WPF,XAML。 找了好久的资源,附有很多很详细的插图,是大数据时代不可缺少的可视化学习数据,仅供大家学习使用请勿用做商业用途。与大家一起...
Prism-Samples-Wpf-master11-15的VS2017版本实现,下载手动重新安装一下nuget包即可,方便大家学习
该资源"practical-wpf-charts-graphics-master.rar"包含了这本书的源代码,为读者提供了丰富的实践案例和深入理解WPF图表及图形编程的宝贵材料。 WPF(Windows Presentation Foundation)是.NET Framework的一部分...
gong-wpf-dragdrop-develop.rar
WPF-Ribbon则是专门针对WPF平台实现的Ribbon组件,它为开发者提供了在WPF应用程序中集成这种现代用户界面的能力。 1. **Ribbon布局** - Ribbon界面通常包含多个主要区域:快速访问工具栏(QAT)、主选项卡、上下文...
在“c#-的WPF---MVVM例子”中,我们可能会看到以下关键概念: 1. **数据绑定**:WPF的强项之一就是其强大的数据绑定功能。通过数据绑定,View中的UI元素可以直接与ViewModel中的属性关联,当ViewModel中的数据改变...
这就是WPF-Math,也被称为dotnet-WPFMath库的用武之地。这个库专门设计用于在WPF应用程序中渲染LaTeX格式的数学公式,让开发者能够轻松地将高质量的数学内容融入他们的应用。 LaTeX是一种基于TeX的文字处理系统,...
C#开发WPF-Silverlight动画及游戏系列教程-深蓝色右手 C#开发WPF-Silverlight动画及游戏系列教程-深蓝色右手 C#开发WPF-Silverlight动画及游戏系列教程-深蓝色右手
C#开发WPF-Silverlight动画及游戏系列教程-深蓝色右手 C#开发WPF-Silverlight动画及游戏系列教程-深蓝色右手 C#开发WPF-Silverlight动画及游戏系列教程-深蓝色右手