Question

I am trying to play Youtube videos which are populated in a LongListSelector. The videos are playing without any issue but when i hit back to come back to the page where LongListSelector is, i am no longer able to play the same video again. The SelectionChanged event is not firing on the videos that i have played. the tilteffect is there when i tap the video but nothing else.

private void MainListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            LongListSelector longListSelector = sender as LongListSelector;

            if (longListSelector != null && longListSelector.SelectedItem != null)
            {
                // Get the SyndicationItem that was tapped.
                YoutubeVideo video = (YoutubeVideo)longListSelector.SelectedItem;
                NavigationService.Navigate(new Uri("/DetailsPage.xaml?VideoId=" + video.Id , UriKind.Relative));
            }
        }
Was it helpful?

Solution

Could you post your selection changed event? I think that issue is happening because you didn't reset the selected item. Try this out:

    private void longListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        // If selected item is null (no selection) do nothing
        if (longListSelector.SelectedItem == null)
            return;

        // Do some work here

        // Reset selected item to null (no selection)
        longListSelector.SelectedItem = null;
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top