Вот мой код:
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)
{
}
}
Он компилируется, но когда я хочу создать экземпляр моего типа, он вылетает со следующей ошибкой:
{"Default value type does not match type of property 'PointValue'."}
Так что я вроде уверен, что проблемаэто:
new PropertyMetadata(0)
но насколько я понимаю PropertyMetadata он должен работать, так как есть конструктор Point, который принимает в качестве параметра int: http://msdn.microsoft.com/en-us/library/bf1b4f2b.aspx
Итак ... что не так