简体   繁体   English

如何以编程方式单击ListView项?

[英]How Can I Click a ListView Item Programatically?

Is this possible? 这可能吗? UWP doesn't seem to have a Select() method like in WinForms. UWP似乎没有WinForms中的Select()方法。 I have tried MyListView.SelectedItem = MyListView.Items[0]; 我已经尝试过MyListView.SelectedItem = MyListView.Items[0]; , but it only highlights the item and does not fire the ItemClick event, which is what I would like. ,但只会突出显示该项目,而不会触发ItemClick事件,这正是我想要的。

Solution: 解:

If I am not mistaken, ListView has a property called selected index which might do the trick. 如果我没记错的话,ListView有一个称为selected index的属性,可以解决这个问题。 If you select the item and then were to manually call the method that the event fires you could produce the same result. 如果选择该项目,然后手动调用事件触发的方法,则可能会产生相同的结果。 I think that if selected index does not work you might just have to manually call the method and select the item you were hoping for. 我认为,如果选择的索引不起作用,则可能只需要手动调用该方法并选择想要的项目即可。

启用IsItemClickEnabled并将其设置为True

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

相关问题 如何以编程方式从viewmodel中选择listview项? - How can I programatically select a listview item from within the viewmodel? 如何从列表视图中查看一个项目,当我单击列表视图的该项目时,它将在文本块上显示数据? - How can i view an item from a listview that when I click on that item of the listview it will show data on a textblock? 如果未在列表视图中选择任何项目,如何禁用右键单击菜单 - How can i disable right click menu if there is no item selected in listview 如何以编程方式更改Better ListView Item的值? - How to change value of Better ListView Item programatically? 通过编程选择一个虚拟ListView项目后,如何使Shift + Click正常工作? - After selecting a virtual ListView item programmatically, how can I make Shift+Click work correctly? 我如何在C#WPF中在ListView中添加ContextMenu(想在某人确实单击ListView项目时添加“修改”操作) - How i can add ContextMenu in ListView (want to add “Modify” operation when someone do right click on ListView item ) in C# WPF 如何在ListView中删除项目? - How I can remove a item in my ListView? 如何取消选择 ListView 中的项目? - How can I unselect item in ListView? 如何确定ListView中是否未选中项目 - How can I identify if item is uncheck in ListView 如何获取 ListView 项的高度? - How can I get the height of a ListView item?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM