WPF Designer “Could not create an instance of type”

后端 未结 11 1264
悲&欢浪女
悲&欢浪女 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:25

    I found a very useful solution to this on : http://www.progware.org/Blog/post/WPF-Designer-Error-Could-not-create-an-instance-of-type.aspx.

    This link explains how the WPF designer window runs the Constructor to display the UI in XAML and the remedy: adding the following snippet to any part of constructor code which might be giving error:

    if(!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
    {
       //code producing exception         
    }
    

    the function name is self explanatory. :) This link also provides solutions on debugging issues with XAML.

提交回复
热议问题