我試圖定義一個依賴項屬性是這樣的:WPF依賴屬性錯誤
public static readonly DependencyProperty DependencyPropertyName= DependencyProperty.Register("DepName", typeof(EnumName), typeof(MyWindow1), new FrameworkPropertyMetadata("FrameWorkProperty", FrameworkPropertyMetadataOptions.AffectsRender, Target));
private static void Target(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
{
//some logic here
}
public EnumName DepName
{
get { return (EnumName)GetValue(DependencyPropertyName); }
set { SetValue(DependencyPropertyName, value); }
}
,我得到這個錯誤,並且不明白爲什麼:
{"Default value type does not match type of property 'DepName'."}
這可能會幫助:http://stackoverflow.com/questions/20398751/the-default-value-type-does-not-match-the-type-of-the-property –