LongListSelector: Item tap?

后端 未结 6 711
执念已碎
执念已碎 2020-12-02 20:39

I am using LongListSelector control on Windows Phone 8 and can\'t figure out the best way to handle a tap on an item. The few examples I\'ve found rely on the SelectionChang

6条回答
  •  温柔的废话
    2020-12-02 20:52

    You could null your LongListSelector's SelectedItem at the end of each SelectionChanged event. I.e.

    
    

    And the event handler:

    private void LLS_SelectionChanged(object sender, SelectionChangedEventArgs e) {
    
      // If selected item is null, do nothing
      if (LLS.SelectedItem == null)
        return;
    
      // Navigate to the next page
      NavigationService.Navigate(new Uri("/nextpage.xaml", UriKind.Relative));
    
      // Reset selected item to null
      LLS.SelectedItem = null;
    }
    

    You'll fire the SelectionChanged event twice, but nothing's going to happen the second time round and you should get the behaviour that you're looking for - (i.e Setting SelectedItem to null will trigger a new SelectionChanged event, but this second event gets caught in the if-statement)

    As for the second part of your question, you might be better posting a new question.

提交回复
热议问题