這是我第一次做xaml所以請理解,我可能會在學習緩慢從JSON響應數據綁定到Listbox
以下是我的CS代碼。我試圖將「屬性」綁定到列表框。
public DirectionPage()
{
InitializeComponent();
List<Feature> features = App.dResult.directions[0].features;
foreach (Feature f in features)
{
Attributes a = f.attributes;
MessageBox.Show(a.text);
}
}
public ObservableCollection<Feature> test = new ObservableCollection<Feature>();
以下是XAML代碼。
<ListBox x:Name="directionListBox" ItemsSource="{Binding}" >
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<TextBlock Text="{Binding text}" Style="{StaticResource PhoneTextTitle2Style}" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
任何幫助將不勝感激。
將您的代碼粘貼爲**文本**,而不是**圖片** .. –