WPF, 'Object reference not set to an instance of an object' in Designer

后端 未结 8 2273
一个人的身影
一个人的身影 2020-12-01 08:58

I\'m getting an \"Object reference not set to an instance of an object\" error when I try to reload the Designer for my XAML UserControl. Visual Studio highlig

8条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 09:40

    It's probably something in the constructor of your user controls. VS2008 WPF designer appears have some issues with this.

    In a project we took over, we added:

    if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
    {
        return;
    }
    

    to the beginning of the constructor of the user controls where this happens to avoid that error.

提交回复
热议问题