我有一个自定义依赖属性,定义如下:
public static readonly DependencyProperty MyDependencyProperty =
DependencyProperty.Register(
"MyCustomProperty", typeof(string), typeof(MyClass));
private string _myProperty;
public string MyCustomProperty
{
get { return (string)GetValue(MyDependencyProperty); }
set
{
SetValue(MyDependencyProperty, value);
}
}
现在我尝试在XAML中设置该属性
<controls:TargetCatalogControl MyCustomProperty="Boo" />
但是,在DependencyObject中的 setter 没有被调用!当我将属性更改为普通属性而不是Dep Prop时,它会被调用。