点击手势作为选择,用于列表框 [英] Tap gesture as select, for listbox
本文介绍了点击手势作为选择,用于列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何为它创建一个事件来检测用户是否点击了列表框中的项目
How do i create an event for it to detect that the user tapped on the item in listbox
<!--Pivot Control-->
<controls:Pivot Title="MY APPLICATION">
<!--Pivot item one-->
<controls:PivotItem Header="item1">
<ListBox x:Name="lbFiles" HorizontalContentAlignment="Stretch" ItemTemplate="{StaticResource DataTemplate1}">
</ListBox>
</controls:PivotItem>
<!--Pivot item two-->
<controls:PivotItem Header="item2">
</controls:PivotItem>
</controls:Pivot>
背后的代码
private void lbFile_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
selected = lbFiles.SelectedItem.ToString();
general item = new general();
item.viewimage(selected);
NavigationService.Navigate(new Uri("/View.xaml", UriKind.Relative));
}
头疼谢谢!:D
推荐答案
您没有附加 SelectionChanged 事件.你在那里有一个函数,但你没有使用它.
You're not attaching the SelectionChanged event. You have a function for it there, but you're not making anything use it.
<ListBox x:Name="lbFiles" HorizontalContentAlignment="Stretch" SelectionChanged="lbfile_SelectionChanged" ItemTemplate="{StaticResource DataTemplate1}">
</ListBox>
您需要附加事件才能使用它们.您应该阅读 create.msdn 上的前几个 WP7 教程 - 您会找到很多入门所需的内容,并对此类事情感到更自在.
You need to attach events so that they are used. You should go through the first few WP7 tutorials on create.msdn - you'll find a lot of what you need to get started and feel more comfortable about things like this.
这篇关于点击手势作为选择,用于列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文