This should be a trivial Task but I can't find how to do it. I want to listen to a click on an item in a listview, get the corresponding model object, and launch a new screen.
This is the XAML for the ListView:
<ListView x:Name="ItemListView"
ItemTemplate="{StaticResource StoreFrontTileTemplate}"
ItemContainerStyle="{StaticResource StoreFrontLVTileStyle}"
Margin="0" VerticalAlignment="Top" ItemClick="MyClick" Tapped="MyTap"/>
And MyClick, MyTap:
private void MyClick(object sender, ItemClickEventArgs e)
{
Debug.WriteLine("Click!");
}
private void MyTap(object sender, TappedRoutedEventArgs e)
{
Debug.WriteLine("TAp!!" + sender.ToString() + "--" + e.ToString());
}
The method to navigate to the new screen:
this.Frame.Navigate(typeof(SecondScreen));
It works, but I need the model object of the clicked item and pass it as a Parameter to the second screen.
But MyClick is never called, and MyTap doesn't give me any Information about the clicked item. "sender" is the ListView.
I downloaded these exaples:
http://code.msdn.microsoft.com/windowsapps/XAML-ListView-sample-pack-0ec6b60f
But it doesn't contain what I need, there's a master / detail view, but it works with bindings and what I want to do is launch a complete new screen.
Note: I'm a noob in Windows development and orienting to the usual way to do it in Android or IOS where you implement a callback with the position of the clicked element. No idea about the right way to do it in Windows 8.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…