これが私のコードです:
public class ExoticPoint : DependencyObject
{
public Point PointValue
{
get { return (Point)GetValue(PointValueProperty); }
set { SetValue(PointValueProperty, value); }
}
public static readonly DependencyProperty PointValueProperty =
DependencyProperty.Register("PointValue", typeof(Point), typeof(ExoticPoint), new PropertyMetadata(0));
public string Description
{
get { return (string)GetValue(DescriptionProperty); }
set { SetValue(DescriptionProperty, value); }
}
public static readonly DependencyProperty DescriptionProperty =
DependencyProperty.Register("Description", typeof(string), typeof(ExoticPoint), new UIPropertyMetadata(0));
public ExoticPoint()
{
}
public ExoticPoint (string objectName)
: base(objectName)
{
}
}
コンパイルされますが、自分のタイプの CreateInstance を実行したい場合、次のエラーでクラッシュします:
{"Default value type does not match type of property 'PointValue'."}
だから、問題は次のとおりだと確信しています:
new PropertyMetadata(0)
しかし、PropertyMetadata を理解する限り、パラメーターとして int を取る Point コンストラクターがあるため、動作するはずです: http://msdn.microsoft.com/en-us/library/bf1b4f2b.aspx
それで...何が悪いのですか?