问题
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
onInputBinding
. You can bind the Command property of anInputBinding
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