방금 Grid App 템플릿을 사용하여 새 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()));
}
참고 : 여기에 관련되지 않은 C # 코드를 이미 건너 뛰었습니다. 코드를 실행하면 KeyNotFoundException이 사용자 코드에 의해 처리되지 않았고이 코드 줄을 그려진 선으로 참조한다는 예외가 발생합니다. var sampleDataGroups = await SampleDataSource.GetGroupsAsync ();
값을 어디에서 초기화 / 설정 itemValue
합니까? 이 항목에 액세스하려는 모든 키가 포함되어 있는지 확인 했습니까?
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다