[英]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
事件,这正是我想要的。
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.