が私のコードです:"System.Windows.Point"タイプのDependencyPropertyを登録するPropertyMetadata?ここで
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
だから何が間違っていますか?
新しいPropertyMetadata(新しいPoint(0))を試しましたが、クラッシュして戻ってきました。実際には、文字列のためにクラッシュしていた、そのような時間の無駄... :( –