说我有以下依赖属性:
public static readonly DependencyProperty IsActiveProperty = DependencyProperty.Register(
"IsActive",
typeof(bool),
typeof(MyAttachedProp),
new PropertyMetadata(false));
以下属性访问者模式之间有什么区别:
public static void SetIsActive(DependencyObject obj, bool value)
{
obj.SetValue(IsActiveProperty, value);
}
public static bool GetIsActive(DependencyObject obj)
{
return (bool)obj.GetValue(IsActiveProperty);
}
VS
public bool IsActive
{
get
{
return (bool)GetValue(IsActiveProperty);
}
set
{
SetValue(IsActiveProperty, value);
}
}
我假设你使用哪一个取决于你的创作,例如附加财产/行为,转换器,控制等?