单击列表视图项目发送到另一个页面

List view item on click send to another page

我有这样的东西:

XAML(对于一项):

  <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));
    }

我想这样做:当我点击第一个项目时,它应该将我带到另一个页面。

您必须像这样向列表视图项添加点击侦听器:

 <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>

你可以在代码隐藏文件中添加这个:

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));
    }

我希望这是你想要的。