似乎在Windows Phone 7.0中列表框没有Tap事件处理程序,因为在7.1中
我找到了SelectionChanged事件,但是这个事件会导致问题.那么7.0中的Tap会有不同的事件吗?
private void flightlist_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
PhoneApplicationService.Current.State["Flight"] = flightlist.SelectedItem;
NavigationService.Navigate(new Uri("/FlightDetail", UriKind.Relative));
}
Run Code Online (Sandbox Code Playgroud)
在Silverlight工具包有GestureListener,让您柄敲击,DoubleTap,还有更多的事件.
它可以附加任何元素.但无论如何,使用自定义点击处理程序,对于SelectionChanged事件的用途,都是一个愚蠢的想法.你应该澄清它为什么"给你带来问题".
更新
将代码修改为:
private void flightlist_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (flightlist.SelectedItem != null)
{
PhoneApplicationService.Current.State["Flight"] = flightlist.SelectedItem;
NavigationService.Navigate(new Uri("/FlightDetail", UriKind.Relative));
}
// reset the selected-index, so the user can click on it again, after returning.
flightlist.SelectedIndex = -1;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2589 次 |
最近记录: |