我有这门课
public class Tooth
{
public string Id {get;set;}
}
Run Code Online (Sandbox Code Playgroud)
而这个custrom控制
public partial class ToothUI : UserControl
{
public ToothUI()
{
InitializeComponent();
}
public Tooth Tooth
{
get { return (Tooth)GetValue(ToothProperty); }
set
{
SetValue(ToothProperty, value);
NombrePieza.Text = value.Id.Replace("_",String.Empty);
}
}
public static readonly DependencyProperty ToothProperty =
DependencyProperty.Register("Tooth", typeof(Tooth), typeof(ToothUI), new PropertyMetadata(0));
}
Run Code Online (Sandbox Code Playgroud)
我的问题是在Add Tooth依赖项属性之后,发生此错误
默认值类型与属性的类型不匹配
这个错误究竟是什么意思?目前设置此方法的方式是什么DP