GridView item selection on windows 8 touch

3 posts, 0 answers
  1. Ken
    Ken avatar
    104 posts
    Member since:
    Aug 2010

    Posted 22 Jan 2014 Link to this post


    We are using the GridView in our Silverlight apps in some master-details views. To detect selection of an item in the GridView we don't use the "SelectedItem" property, but rather subscribe to a "MouseLeftButtonUp" event on a control in the data template of the grid view cell.

    This works perfectly fine when using a mouse, however, when running the app in desktop mode on a windows 8 machine and using touch (i.e. finger) to select an item in the view, it doesn't work properly. What happens is that the actual item in the GridView gets selected (selected color overlay is activated) but no MouseLeftButtonUp (or MouseLeftButtonDown) event is raised. Due to the fact that the data template of the cell is a ContentControl we can't subscribe to a Click event because it doesn't exist on ContentControl.

    As far as I read on MSDN, when using touch the touch/tap events are promoted to normal mouse events. This seems to indeed be the case as the item in the grid gets selected. However, no further mouse button events are raised to our code.

    Any ideas how to fix this?

  2. Vera
    Vera avatar
    263 posts

    Posted 24 Jan 2014 Link to this post

    Hi Adrian,

    Usually, clicking on a control in the GridView is handled by mouse only. In order to be able to fire the mouse events with touch, you have to set TouchManager.IsTouchHitTestVisible to false on the control. Please set the property on the control in your data template and let me know in case you still experience any problems.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Ken
    Ken avatar
    104 posts
    Member since:
    Aug 2010

    Posted 24 Jan 2014 Link to this post

    Hi Vera,

    Thanks a lot for the answer, it works :)

    Have a nice weekend,
Back to Top