All WPF control properties are dependency properties. True or False?

对着背影说爱祢 提交于 2019-12-12 15:09:10

问题


While answering this question I noticed that I have never come across any property which is not a dependency property (WPF Controls, no 3rd party controls). Although, when I started with WPF I remember reading somewhere that "more then 90% of properties of WPF controls are dependency properties".

Can anyone give examples/links of CLR properties in WPF controls and why it's so?

Update:

Came across this lecture: http://www.miszalok.de/Lectures/L17_WPF/C4_DependencyProperties/DependencyProperties.pdf

Which says:

Label has 18 traditional and 71 dependency properties.

Button has 18 traditional and 78 dependency properties.


回答1:


The PasswordBox property Password is not implemented as dependency property to not allow data binding, which would be a security risk otherwise. See this post for details.




回答2:


Panel.Children or FrameworkElement.Resources are not dependency properties




回答3:


Also the CommandParameters pre WPF 4 was CLR properties!

Taken from MSDN:

Bind to commands on InputBinding. You can bind the Command property of an InputBinding class to an instance that is defined in code. The following properties are dependency properties, so that they can be targets of bindings:

  • InputBinding.Command
  • InputBinding.CommandParameter
  • InputBinding.CommandTarget
  • KeyBinding.Key
  • KeyBinding.Modifiers
  • MouseBinding.MouseAction

http://msdn.microsoft.com/en-us/library/bb613588.aspx



来源:https://stackoverflow.com/questions/3767867/all-wpf-control-properties-are-dependency-properties-true-or-false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!