WPF Designer “Could not create an instance of type”

后端 未结 11 1265
悲&欢浪女
悲&欢浪女 2020-12-20 11:45

In my UI XAML I\'m essentially inheriting from a class \"BaseView\" that contains functionality common to several forms, however this is preventing the designer from display

11条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-20 12:22

    Another cause. My control class had a static field that was initialized from resources, like this:

     static Color s_ImgColor = (Color)TheApp.Resources["PhoneForegroundColor"];
    

    That would throw a null reference exception in XAML editor, since the resources are not available in design mode. Were it not a color resource (say, a brush), this won't be a problem, but a typecast to value type throws up on a null reference.

提交回复
热议问题