WPF设计器“无法创建类型的实例” [英] WPF Designer "Could not create an instance of type"

查看:825
本文介绍了WPF设计器“无法创建类型的实例”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的UI XAML中,我基本上继承了一个BaseView类,它包含多个表单共有的功能,但是这阻止了设计者显示表单:无法创建BaseView类型的实例。代码将编译并运行,但是不能在Designer中看到该表单是令人沮丧的。有没有更好的办法?谢谢。

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 displaying the form: "Could not create instance of type BaseView". The code will compile and run, but it is frustrating not to be able to see the form in the Designer. Is there a better way? Thanks.

XAML:

<vw:BaseView 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:vw="clr-namespace:ReviewClient"   
    x:Class="ReviewClient.MainPage"

...

推荐答案

问题是基类被定义为抽象。这导致设计师失败。 Laurent Bugnion博客的评论部分更详细地描述了这个问题: http ://geekswithblogs.net/lbugnion/archive/2007/03/02/107747.aspx

The problem was that the base class was defined as abstract. This caused the designer to fail. This problem is described in more detail in the comments section of Laurent Bugnion's blog: http://geekswithblogs.net/lbugnion/archive/2007/03/02/107747.aspx

这篇关于WPF设计器“无法创建类型的实例”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆