【发布时间】:2014-09-30 22:36:23
【问题描述】:
我有一个包含堆栈面板的数据绑定列表框,其中包含许多文本框,并且文本正在从服务器动态加载。这就是 XAML 的样子-
<ListBox x:Name="SearchColl_List" ItemsSource="{Binding }" >
<ListBox.ItemTemplate>
<DataTemplate>
<!--Main Stack-->
<StackPanel x:Name="Coll_Stack" Orientation="Vertical"
Margin="10,0,6,20"
Tap="StackPanel_Tap">
<TextBlock x:Name="Name_Text"
Text="{Binding Name}"
FontSize="20"
Width="450"
HorizontalAlignment="Left"
Foreground="#33706b"
TextWrapping="Wrap"
/>
<TextBlock Text="{Binding Stream}"
Width="450"
HorizontalAlignment="Left"
FontSize="20"
Foreground="Green"
TextWrapping="Wrap"
/>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
我有一个事件“StackPanel_Tap”,我想访问“Name_Text”(TextBox) 中的文本以获取正在点击的堆栈面板元素。我想访问下面的方法存根中的文本...
private void StackPanel_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
//Access the Text in "Name_Text" for current element that is tapped
}
【问题讨论】:
-
你不能用
Name_Text.Text吗? -
不,我不能使用它,因为它存在于绑定的文本框中..
标签: c# xaml windows-phone-8 data-binding listbox