谁能告诉我如何将数据绑定到列表框。
listbox_mypet.ItemsSource = pg_addPet.list_listMyPet;
我的课是
public class SaveMypet
{
public string Name { get; set; }
public string Birthday { get; set; }
public string FavFood { get; set; }
public string DocNo { get; set; }
public string VacDate { get; set; }
public string FavToy { get; set; }
// public ImageSource Image1 { get; set; }
}
我的代码不起作用
<ListBox Foreground="Black" FontSize="24" Canvas.Left="20" Canvas.Top="80" Height="313" Name="listbox_mypet" Width="415" Margin="20,80,-435,-393">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}"> </TextBlock>
<TextBlock Text="{Binding Birthday}"> </TextBlock>
<TextBlock Text="{Binding FavFood}"> </TextBlock>
<TextBlock Text="{Binding DocNo}"> </TextBlock>
<TextBlock Text="{Binding VacDate}"> </TextBlock>
<TextBlock Text="{Binding FavToy}"> </TextBlock>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
它显示 System.Windows.Controls.TextBox