C# 仅由XAML设计器引发的PhoneApplicationPage子类化错误
在我的Windows Phone 7.1应用程序中,我有一些页面是这样制作的:C# 仅由XAML设计器引发的PhoneApplicationPage子类化错误,c#,visual-studio-2010,xaml,inheritance,windows-phone-7.1,C#,Visual Studio 2010,Xaml,Inheritance,Windows Phone 7.1,在我的Windows Phone 7.1应用程序中,我有一些页面是这样制作的: <views:EntityListPage x:Class="Ribo.Smart.X.CustomersPage" x:Name="MainWindow" xmlns:views="clr-namespace:Ribo.Smart.X.Views" xmlns="http://s
<views:EntityListPage x:Class="Ribo.Smart.X.CustomersPage"
x:Name="MainWindow"
xmlns:views="clr-namespace:Ribo.Smart.X.Views"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
mc:Ignorable="d"
d:DesignWidth="480"
d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
Loaded="MainWindow_Loaded"
SupportedOrientations="Portrait"
Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<views:EntityListPage.Resources>
....
</views:EntityListPage.Resources>
...
</views:EntityListPage>
其中myEntityListPage
类的定义如下:
public abstract class EntityListPage : PhoneApplicationPage
{
... a lot of stuff here! ...
}
如果我运行这段代码,所有代码都可以正常工作,并且没有任何类型的编译/构建错误
但是,如果我打开CustomerPage视图的XAML设计器,它将无法加载我页面的布局,并且它将显示下一个错误(但不会干扰项目!):
我不明白为什么设计师不能向我展示布局并给出错误,而在运行时一切正常,我没有任何问题/异常
谢谢大家! 非常简单:问题就在您的
实体列表页面上,这是抽象的
如果删除祖先类的abstract
子句,并将所有方法转换为virtual
方法(而不是abstract
方法,否则需要将整个类设置为abstract
),则设计器应该没有问题
这是一个奇怪的错误,但它是可以管理的
希望这有帮助
public abstract class EntityListPage : PhoneApplicationPage
{
... a lot of stuff here! ...
}
Cannot create an instance of "EntityListPage".