windows-8microsoft-metrosemantic-zoom

It is possible to select a ListView item with a single tap or left click?


I am developing a Windows 8 metro application that uses semantic zoom in the following way:

What do I want:

When the user taps or clicks on an item in the zoomed out view, the zoomed in view should activate and the control matching the clicked item should be made visible (the zoomed in ListView allows scrolling, so the control could be hidden). I know how to do this as long as the SelectionChanged event is triggered when a item is clicked.

What happens instead:

When the user taps or clicks on an item in the zoomed out view, the zoomed in view activates automatically and no SelectionChanged event is triggered. However, it works fine when using right click or Ctrl+click instead.

So, my question is:

Is there any way to make a ListView trigger the SelectionChanged event on item tap or left click, in addition to right click and Ctrl+click? If not, how can I detect the tap or left click?

Thank you very much!


Solution

  • I found out the solution. I must control the Tapped event of the control that is inside the defined DataTemplate for the list, NOT the event of the ListView itself:

    <SemanticZoom...>
        <SemanticZoom.ZoomedOutView>
            <ListView ...>
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Border ... Tapped="Item_Tapped">
    

    And in the Item_Tapped method, I just cast sender to FrameworkElement and look at its DataContext.