Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在WP7中使用DataGrid_C#_Windows Phone 7_Datagrid - Fatal编程技术网

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.