ListView Item Selection Windows Store

寵の児 提交于 2019-12-11 11:36:23

问题


I want a ListView to behave like this:

With mouse Input:

  • Left Click -> Item click event handler gets executed, but should not display it as "selected"
  • Right Click -> Item gets selected

With touch Input:

  • Single Tap -> equivalent to left click
  • Swipe Down -> equivalent to right click

I have played around with various of the events and settings but cant seem to get it to work right.


回答1:


In other words, you want your listview to behave like the Windows Start screen? This one was brutal for me to figure out - the mouse part was easy, but the touch part not so much. The solution turns out to be pretty easy. You just have to enable the right options for your listview. Here's the xaml for mine:

<ListView
        x:Name="itemListView"
        SelectionMode="Extended"
        IsSwipeEnabled="True"
        IsItemClickEnabled="True"
        ItemClick="ItemView_ItemClick"
        />

Sorry, I haven't figured how to get code to highlight in StackOverflow yet.




回答2:


This could help you with the mouseclicks

 private void MainForm_MouseDown(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
            method()
        if (e.Button == MouseButtons.Right)
            set selection = false
            method()
    }

and for the handle of the touch i hope this helps

http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh465387.aspx



来源:https://stackoverflow.com/questions/13470083/listview-item-selection-windows-store

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!