当我使用从基类继承而继承自依赖关系对象的模型时,我在UWP中遇到win32未处理的异常。
我将xaml中的属性定义为以下代码。
代码
public abstract class BaseModel : DependencyObject
{
...
}
public class MainModel : BaseModel
{
// Dependency Property
public bool ShowLabel
{
get { return (bool)GetValue(ShowLabelProperty); }
set { SetValue(ShowLabelProperty, value); }
}
public static readonly DependencyProperty ShowLabelProperty =
DependencyProperty.Register("ShowLabel", typeof(bool), typeof(MyModel), new PropertyMetadata(false));
...
}
模型的样本级别声明
<mycontrol:MyModel ShowLabel="True" />
如果我在模型中定义任何属性,则会产生此问题。
示例链接:https://1drv.ms/u/s!Aml_7nNZeX6ka7-sLQtjaUb_7a4
此致
塞缪尔