C# 在WP7中使用DataGrid
我需要在数据网格中显示我的数据。我正在使用以下代码: 前端: 命名空间:C# 在WP7中使用DataGrid,c#,windows-phone-7,datagrid,C#,Windows Phone 7,Datagrid,我需要在数据网格中显示我的数据。我正在使用以下代码: 前端: 命名空间:xmlns:datagrid=“clr命名空间:System.Windows.Controls;assembly=System.Windows.Controls.Data” <datagrid:DataGrid Name="tgrid" AutoGenerateColumns="False" Grid.Row="2" HeadersVisibility="Column"> <
xmlns:datagrid=“clr命名空间:System.Windows.Controls;assembly=System.Windows.Controls.Data”
<datagrid:DataGrid Name="tgrid" AutoGenerateColumns="False" Grid.Row="2" HeadersVisibility="Column">
<datagrid:DataGrid.Columns>
<datagrid:DataGridTextColumn Header="Name">
</datagrid:DataGridTextColumn>
</datagrid:DataGrid.Columns>
</datagrid:DataGrid>
您显示的异常似乎与您未显示的某些XAML有关。附加的
x:Class
属性表示用户控件的代码隐藏类。项目中是否存在类型projectName.MainPage
我建议使用新的用户控件重新开始,放慢代码的添加速度,在缓慢添加代码时重新编译并运行。projectName.MainPage存在于我的项目中。当我对datagrid部分进行注释时,程序照常执行。
List<LItem> str = new List<LItem>();
str.Add(new LItem() { Str = "chandra" });
str.Add(new LItem() { Str = "chandra" });
str.Add(new LItem() { Str = "chandra" });
str.Add(new LItem() { Str = "chandra" });
str.Add(new LItem() { Str = "chandra" });
str.Add(new LItem() { Str = "chandra" });
tgrid.ItemsSource = str;
public class LItem
{
private string _str;
public string Str
{
get { return _str; }
set { _str = value; }
}
}
The type 'projectName.MainPage', specified in the x:Class of '/MainPage.xaml' could not be found in any loaded assembly.