从依赖项对象继承并在xaml中声明属性时Win32未处理的异常?

时间:2017-04-25 04:39:22

标签: c# xaml uwp uwp-xaml

当我使用从基类继承而继承自依赖关系对象的模型时,我在UWP中遇到win32未处理的异常。

Win32 Unhandled Exception - link for exception image

我将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

此致

塞缪尔

0 个答案:

没有答案