0

Problem:

I have a list, using LongListSelector, of videos. When a video is selected, it launches the MediaPlayerLauncher. If a user presses the back key to close the video (or, even presumably when the video reaches the end), and tries to select the same video they were just watching, the MediaPlayer does not activate (because the selection isn't changed, duh!).

So...any suggestions to my problem?

Thank you to anyone that answers!

user3007447
  • 380
  • 3
  • 15
  • same problem here : http://stackoverflow.com/questions/14215227/longlistselector-item-tap – har07 Dec 28 '13 at 01:25

3 Answers3

0

Then don't use "SelectionChanged" event. Maybe use "Tap" event, so that the event will be raised every time the item tapped no matter it was different item or the same as previously selected item.

har07
  • 88,338
  • 12
  • 84
  • 137
0
private void LongListSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        // your code here
        e.AddedItems[0] = null;
    }

[Edit]

AddedIems is a list of your selected item. So set the fisrt item [0] to null for cancel the selection

Jerome
  • 63
  • 5
  • Please try to add at least basic explanation for every answer. Code-only posts are automatically marked as low quality. – zero323 Dec 22 '13 at 11:52
0
e.AddedItems[0] = null;

does not work for me. But I actually have the answer:

    private void videosList_SelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        // Make sure the videos actually loaded into the LongListSelector before allowing a selection.
        if (e.AddedItems.Count != 0)
        {
            // If selected item is null (no selection) do nothing
            if (videosList.SelectedItem == null)
                return;

            Video v = videosList.SelectedItem as Video;
            App.Current.Resources.Add("video", v);
            //NavigationService.Navigate(new Uri("/Pages/VideoPlayer.xaml", UriKind.RelativeOrAbsolute));
            LoadVideosMediaLauncher();

            // Reset selected item to null (no selection)
            videosList.SelectedItem = null;
        }
    }

videosList is the name of my LongListSelector.

user3007447
  • 380
  • 3
  • 15