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

后端 未结 8 2271
一个人的身影
一个人的身影 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:45

    If you have 'Object reference not set to an instance of an object' in XAML, but your application compiles and runs fine, you will usually find out that its cause is something in a constructor that can't be resolved at design time.

    While you can find out the root of the problem with the help of other answers to this question, sometimes that is something you can't simply fix, you need it in your code exactly as you have it, but you don't want to see this error.

    In this case, just click the "Disable project code" button located on the bottom of your designer view and Visual Studio designer will stop trying to construct an instance to provide design time data view.

    See here for detailed information.

提交回复
热议问题