WPF Page 继承问题
xaml文件:
<my:UC_Base x:Class="MyWpfTest.Page1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:MyWpfTest"
Title="Page1" Height="600" Width="800">
<Grid>
<ListView Name="myListView" ItemsSource="{Binding}" Margin="0,120.862,0,0">
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding Path=A1}" Header="First Name" Width="100" />
<GridViewColumn DisplayMemberBinding="{Binding Path=B1}" Header="Last Name" Width="100" />
</GridView>
</ListView.View>
</ListView>
</Grid>
</my:UC_Base>
.cs文件:
namespace MyWpfTest
{
public partial class Page1 : UC_Base
{
public Page1()
{
DataTable dt = new DataTable();
dt.Columns.Add("A1", typeof(System.String));
dt.Columns.Add("B1", typeof(System.String));
dt.AcceptChanges();
for (int i = 0; i < 10; i++)
{
DataRow dr = dt.NewRow();
dr["A1"] = i;
dr["B1"] = 10 - i;
dt.Rows.Add(dr);
dt.AcceptChanges();
}
dt.TableName = "Test";
this.myListView.DataContext = dt;
}
}
}
基类文件:
namespace MyWpfTest
{
public class UC_Base : Page
{
}
}
运行后总会报Markup.XamlParseException:Cannot create instance of 'Page1' defined in assembly 'MyWpfTest, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Page1.xaml' Line 1 Position 13.
希望大侠们不吝赐教,感激不尽