[英]Windows 8 Grid App template | Edit Sample Data Source
I just created a new windows 8 app using the Grid App template, and simply i wanted to add a new text block in my xaml code and bind some data to it on each item in the groups, how can I edit the data source and add the new item? 我刚刚使用Grid App模板创建了一个新的Windows 8应用程序,只是想在我的xaml代码中添加一个新的文本块并将一些数据绑定到组中每个项目上,我该如何编辑数据源并添加新项目? my code is as below:
我的代码如下:
<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()));
}
NOTE : I already skipped any C# code that's not related here.. when I run the code i get an exception that says KeyNotFoundException was unhandled by user code and referring to this line of code by a drawn line: var sampleDataGroups = await SampleDataSource.GetGroupsAsync(); 注意:我已经跳过了任何与此处不相关的C#代码。.当我运行代码时,我得到一个异常,该异常表示用户代码未处理KeyNotFoundException,并通过绘制的行引用了此代码行:var sampleDataGroups = await SampleDataSource.GetGroupsAsync ();
Where do you initialize/set the valze of itemValue
? 您在哪里初始化/设置
itemValue
? Did you make sure that this item contains all the keys you want to access? 您是否确定该项目包含您要访问的所有密钥?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.