Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.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# Windows 8网格应用程序模板|编辑示例数据源_C# - Fatal编程技术网

C# Windows 8网格应用程序模板|编辑示例数据源

C# Windows 8网格应用程序模板|编辑示例数据源,c#,C#,我刚刚使用Grid应用程序模板创建了一个新的windows 8应用程序,我只是想在我的xaml代码中添加一个新的文本块,并在组中的每个项目上绑定一些数据,如何编辑数据源并添加新项目?我的代码如下: <XAML> <TextBlock x:Name="Contact" Text="{Binding Contact}" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Height="

我刚刚使用Grid应用程序模板创建了一个新的windows 8应用程序,我只是想在我的xaml代码中添加一个新的文本块,并在组中的每个项目上绑定一些数据,如何编辑数据源并添加新项目?我的代码如下:

 <XAML>

<TextBlock  x:Name="Contact" Text="{Binding Contact}" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Height="471" Margin="1022,101,0,0" RenderTransformOrigin="0.5,0.5" Width="282" FontSize="15"/>


<C# - SampleDataSource>

public class SampleDataItem
{
    public SampleDataItem(String uniqueId, String title, String subtitle, String imagePath, String description, String content, String contact)
    {
        this.UniqueId = uniqueId;
        this.Title = title;
        this.Subtitle = subtitle;
        this.Description = description;
        this.ImagePath = imagePath;
        this.Content = content;
        this.Contact = contact;
    }

public string UniqueId { get; private set; }
    public string Title { get; private set; }
    public string Subtitle { get; private set; }
    public string Description { get; private set; }
    public string ImagePath { get; private set; }
    public string Content { get; private set; }
    public string Contact { get; private set; }


{
                JsonObject itemObject = itemValue.GetObject();
                group.Items.Add(new SampleDataItem(itemObject["UniqueId"].GetString(),
                                                   itemObject["Title"].GetString(),
                                                   itemObject["Subtitle"].GetString(),
                                                   itemObject["ImagePath"].GetString(),
                                                   itemObject["Description"].GetString(),
                                                   itemObject["Contact"].GetString(),
                                                   itemObject["Content"].GetString()));
            }

公共类SampleDataItem
{
public SampleDataItem(字符串唯一标识、字符串标题、字符串字幕、字符串图像路径、字符串描述、字符串内容、字符串联系人)
{
this.UniqueId=UniqueId;
这个.Title=Title;
这个。副标题=副标题;
这个。描述=描述;
this.ImagePath=ImagePath;
这个。内容=内容;
这个.接触=接触;
}
公共字符串唯一ID{get;private set;}
公共字符串标题{get;private set;}
公共字符串字幕{get;private set;}
公共字符串说明{get;private set;}
公共字符串ImagePath{get;private set;}
公共字符串内容{get;private set;}
公共字符串联系人{get;private set;}
{
JsonObject itemObject=itemValue.GetObject();
group.Items.Add(新的SampleDataItem(itemObject[“UniqueId”])。GetString(),
itemObject[“Title”].GetString(),
itemObject[“Subtitle”].GetString(),
itemObject[“ImagePath”].GetString(),
itemObject[“Description”].GetString(),
itemObject[“联系人”].GetString(),
itemObject[“Content”].GetString());
}
注意:我已经跳过了此处不相关的任何C#代码。当我运行代码时,我得到一个异常,该异常表示KeyNotFoundException未由用户代码处理,并通过一条绘制的线引用这一行代码:
var sampleDataGroups=wait SampleDataSource.GetGroupsAsync();

在哪里初始化/设置
itemValue
的值?是否确保此项包含所有要访问的键