简体   繁体   English

UWP:ListView ItemClick不起作用

[英]UWP: ListView ItemClick not work

I have to do a Master/Detail in UWP 我必须在UWP中做主/细节

1- If you're in Laptop: 1-如果您在笔记本电脑中:

The responsible GridView of show the data of this person appear. 显示该人的负责数据的GridView出现。 So when you select a item is binded to ViewModel. 因此,当您选择一个项目时,它将绑定到ViewModel。

<ScrollViewer x:Name="ScrollLista" Grid.Column="0" Grid.Row="1">
            <ListView x:Name="Lista" ItemsSource="{Binding Lista}" ItemClick="Lista_ItemClick" SelectedItem="{Binding PersonaSeleccionada, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding nombre}" />
                            <TextBlock Text="{Binding apellido}" />
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </ScrollViewer>

        <Grid x:Name="CRUD" Grid.Column="1" Grid.Row="1" DataContext="{Binding PersonaSeleccionada}" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
            ...

        </Grid>

2- When is a mobile: 2-什么时候是手机:

Only will appear the list and when I select a item this should be two things. 仅会出现列表,当我选择一个项目时,这应该是两件事。

  1. Call to ViewModel by binding using SelectedItem. 通过使用SelectedItem进行绑定来调用ViewModel。
  2. Call to code behind using ItemClick, this will be in charge of calling another page. 使用ItemClick调用代码背后的代码,这将负责调用另一个页面。

The problem: ItemClick not working, not call to Lista_ItemClick... How can I call a method and send the item selected to code behind? 问题:ItemClick无法正常工作,无法调用Lista_ItemClick ...如何调用方法并将所选项目发送给后面的代码?

为了使单击事件起作用, IsItemClickEnabled="True"添加到ListView。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM