I have something like this:
XAML (for one item):
<ListView Margin="10,0,10,10" Width="360" Height="510" VerticalAlignment="Bottom" RenderTransformOrigin="0.479,0.497">
<ListViewItem RenderTransformOrigin="0.719,0.534">
<StackPanel Orientation="Horizontal">
<Image Source="/Assets/1.png" Margin="0,0,5,0" />
<TextBlock FontSize="20" Width="302" RenderTransformOrigin="0.698,0.49" SelectionChanged="TextBlock_SelectionChanged" IsHoldingEnabled="False" IsDoubleTapEnabled="False">
<Run Text="Stotis–Oro uostas"/>
</TextBlock>
C#:
private void TextBlock_SelectionChanged(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(SecondPage));
}
I want to make like that: When I click on 1st item it should send me to another page.
You have to add tapped listener to the listview items like this:
<ListView Margin="10,0,10,10" Width="360" Height="510" VerticalAlignment="Bottom" RenderTransformOrigin="0.479,0.497">
<ListViewItem x:Name="ListViewItem1" Tapped="ListViewItem1_Tapped">
<!--add your image and text and ...-->
</ListViewItem>
<ListViewItem x:Name="ListViewItem2" Tapped="ListViewItem2_Tapped">
...
</ListViewItem>
<ListViewItem x:Name="ListViewItem3" Tapped="ListViewItem3_Tapped">
...
</ListViewItem>
</ListView>
Than you can add in the code behind file this:
private void ListViewItem1_Tapped(object sender, TappedRoutedEventArgs e)
{
this.Frame.Navigate(typeof(FirstPage));
}
private void ListViewItem2_Tapped(object sender, TappedRoutedEventArgs e)
{
this.Frame.Navigate(typeof(SecondPage));
}
private void ListViewItem3_Tapped(object sender, TappedRoutedEventArgs e)
{
this.Frame.Navigate(typeof(ThirdPage));
}
I hope this is like you wanted it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.