日期:2014-05-18  浏览次数:20831 次

Windows Phone 7中listbox的使用方法,求解答~!
我在listbox里面插入了image,textblock怎么在点击某一项的时候获取textblock的text,求各位大虾帮帮忙啊~!急求~~~![code=C#][/code]
 <ListBox Height="706" ItemsSource="{Binding Source={StaticResource TableNumCollection},Path=DataCollection}" HorizontalAlignment="Left" Name="listBoxTableNum" VerticalAlignment="Top" Width="456" Foreground="White" Background="Black" SelectionChanged="listBoxTableNum_SelectionChanged">
  <ListBox.ItemTemplate>
  <DataTemplate x:Name="Item">
  <StackPanel Orientation="Horizontal">
  <Image Source="{Binding Path=ImageUrl}"/>
  <StackPanel Orientation="Horizontal">
  <TextBlock Text="{Binding TableNums}" Foreground="White"/>
  </StackPanel>
  </StackPanel>
  </DataTemplate>
  </ListBox.ItemTemplate>
  </ListBox>


[code=C#][/code]


  public class TableNums : List<TableNum>
  {
  public TableNums()
  {
  BuildCollection();
  }
  private const string imageUrl = "../Img/";

  public ObservableCollection<TableNum> DataCollection { get; set; }

  public ObservableCollection<TableNum> BuildCollection()//绑定的数据
  {
  DataCollection = new ObservableCollection<TableNum>();
  DataCollection.Add(new TableNum("1 号 桌", imageUrl + "Smile.jpg"));
  DataCollection.Add(new TableNum("2 号 桌", imageUrl + "Smile.jpg"));
  DataCollection.Add(new TableNum("3 号 桌", imageUrl + "Smile.jpg"));
  DataCollection.Add(new TableNum("4 号 桌", imageUrl + "Smile.jpg"));
  DataCollection.Add(new TableNum("5 号 桌", imageUrl + "Smile.jpg"));
  DataCollection.Add(new TableNum("6 号 桌", imageUrl + "Smile.jpg"));
  DataCollection.Add(new TableNum("7 号 桌", imageUrl + "Smile.jpg"));
  DataCollection.Add(new TableNum("8 号 桌", imageUrl + "Smile.jpg));
  DataCollection.Add(new TableNum("9 号 桌", imageUrl + "Smile.jpg));
  DataCollection.Add(new TableNum("10号桌", imageUrl + "Smile.jpg"));
  DataCollection.Add(new TableNum("11号桌", imageUrl + "Smile.jpg"));
  DataCollection.Add(new TableNum("12号桌", imageUrl + "Smile.jpg"));
  return DataCollection;
  }
  }



[code=C#][/code]


  public class TableNum
  {
  public string TableNums { get; set; }
  public string ImageUrl { get; set; }

  public TableNum(string tablenums, string imageurl, string button)
  {
  this.TableNums = tablenums;
  this.ImageUrl = imageurl;
  }

  }

我想要获取TableNums,该怎么在selectionchanged


------解决方案--------------------
通过 sender 去获取