private async void MVSuggestControl_SelectionChanged(object sender, SelectionChangedEventArgs e) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (MVSuggestControl.SelectedItem != null) { MVSuggestControl.ScrollIntoViewSmoothly(MVSuggestControl.SelectedItem, ScrollIntoViewAlignment.Leading); } }); }
public MusicMV() { InitializeComponent(); ThisPage = this; MVSuggestControl.ItemsSource = MVSuggestionCollection; Loaded += async(s, e) => { if (IsSame) { IsSame = false; return; } MVControl.MediaPlayer.PlaybackSession.PlaybackStateChanged += PlaybackSession_PlaybackStateChanged; MVControl.MediaPlayer.MediaFailed += MediaPlayer_MediaFailed; MVControl.Source = MediaSource.CreateFromUri(MovieUri); var Result = await NetEase.GetArtistAsync(ArtistID); foreach (var Song in Result.HotSongs.Where(Song => Song.Mv != 0).Select(Song => Song)) { var MVResult = await NetEase.GetMVAsync((int)Song.Mv); if (MVResult.Data.BriefDesc == "") { MVSuggestionCollection.Add(new MVSuggestion(MVResult.Data.Name, "无简介", (int)Song.Mv, new Uri(MVResult.Data.Cover))); } else { MVSuggestionCollection.Add(new MVSuggestion(MVResult.Data.Name, MVResult.Data.BriefDesc, (int)Song.Mv, new Uri(MVResult.Data.Cover))); } if (MVName.Text == MVResult.Data.Name) { MVSuggestControl.SelectedItem = MVSuggestionCollection[MVSuggestionCollection.Count - 1]; } } if (MVSuggestControl.SelectedItem != null) { MVSuggestControl.ScrollIntoViewSmoothly(MVSuggestControl.SelectedItem, ScrollIntoViewAlignment.Leading); } MVSuggestControl.SelectionChanged += MVSuggestControl_SelectionChanged; }; }