WP7中的ListBox数据绑定问题
System.Collections.ObjectModel.ObservableCollection<GameBoxClass.GameNum> query = new System.Collections.ObjectModel.ObservableCollection<GameBoxClass.GameNum>(); for (int i = 0; i < 5; i++) { query.Add(new GameBoxClass.GameNum { Account = i + "号", Password = "111", PasswordCard = new System.Windows.Media.Imaging.BitmapImage(new Uri("/Images/wow.jpg", UriKind.RelativeOrAbsolute)) }); } AccountList.ItemsSource = query;
<ListBox x:Name="AccountList" Grid.Row="1" > <ListBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Account, Mode=TwoWay}" FontFamily="微软雅黑" Foreground="Black"></TextBlock> </DataTemplate> </ListBox.ItemTemplate> </ListBox>