WPF Designer “Could not create an instance of type”

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

    Yet another possible cause.

    I have a user control which has child controls which generate events e.g. selection_changed on list control. The select_changed event handler makes changes to other child controls.

    During initialisation the selected item property of the list box gets changed and triggers a selection_changed event. The handler tries to update the other child controls but cannot because they have not yet been instantiated. This leads to a null pointer exception and causes the problem.

    Once the null pointer problem was handled the control was able to be instantiated and appeared in the parent control.

提交回复
热议问题