AttachedProperties
private
vs public
哪里有意义? 通常它定义为(例如):Public vs Private AttachedProperties
public static readonly DependencyProperty CommandProperty =
DependencyProperty.RegisterAttached(
"Command",
typeof(ICommand),
typeof(Click),
new PropertyMetadata(OnSetCommandCallback));
但我也看到的例子,其中有些属性是private static readonly...
什么后果,如果我现在改变上述CommandProperty
到private
?如果我这样做,似乎仍然可以在我的XAML intellisense中使用。我在这里错过了什么?
如果附加行为是xaml中的数据绑定,并且被定义为私有? xaml是否会调用静态的Get和Set方法? – VoodooChild
通过Binding或Xaml设置的值将直接调用'GetValue'和'SetValue',这样它们对于私有'DependencyProperty'仍然可以正常工作。公共的getter和setter仍然需要能够找到它 –