在我的 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://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>
这或多或少是我观点背后的代码:
public partial class CustomersPage : EntityListPage
{
public CustomersPage()
{
InitializeComponent();
}
... other stuff here ...
... of course I'm overriding all the methods of the base abstract class ...
... (see the ancestor definition) ...
}
我的EntityListPage
班级以以下方式定义:
public abstract class EntityListPage : PhoneApplicationPage
{
... a lot of stuff here! ...
}
如果我运行此代码,一切正常,也没有任何类型的编译/构建错误!
但是如果我打开我的 CustomersPage 视图的 XAML 设计器,它就无法加载我的页面布局,并且会显示下一个错误(但它不会干扰项目!):
Cannot create an instance of "EntityListPage".
我无法弄清楚为什么设计师不能向我展示布局并给出错误,而在运行时一切正常,我完全没有问题/异常!
谢谢!