private void mediaState_SelectionChanged(object sender, EventArgs e) { List <MediaItem> items = new List <MediaItem>(); MediaStateCollectionView.EnterReadLock(); try { items = MediaStateCollectionView.getSelectedItems_RLock(); if (items.Count == 0) { CurrentPage = null; } else { CurrentPage = MediaStateCollectionView.IndexOf(new SelectableMediaItem(items[0])) + 1; } } finally { MediaStateCollectionView.ExitReadLock(); EventAggregator.GetEvent <MediaSelectionEvent>().Publish(new MediaSelectionPayload(MediaStateCollectionView.Guid, items)); } }
private void mediaStateCollectionView_SelectionChanged(object sender, EventArgs e) { MediaStateCollectionView view = sender as MediaStateCollectionView; Dispatcher.BeginInvoke(new Action(() => { ICollection <MediaItem> selectedItems = view.getSelectedItems(); if (selectedItems.Count == 0) { return; } scrollToIndex = view.IndexOf(new SelectableMediaItem(selectedItems.ElementAt(0))); if (scrollViewer != null) { scrollViewer.ScrollToHorizontalOffset(scrollToIndex); } })); }