예제 #1
0
        private void miDelete_Click(object sender, RoutedEventArgs e)
        {
            TrackListsViewModel trackListsVM = lb_PlaylistMenu.DataContext as TrackListsViewModel;
            Playlist            pl           = lb_PlaylistMenu.SelectedItem as Playlist;

            if (pl == null)
            {
                throw new Exception("Failed to cast selected item to Playlist");
            }

            trackListsVM.RemovePlaylist(pl.GUID);
            lb_PlaylistMenu.SelectedIndex = trackListsVM.TrackLists.Count - 1;

            RefreshPlaylistContent();
        }
예제 #2
0
        private void lb_PlaylistMenu_KeyDown(object sender, KeyEventArgs e)
        {
            // Remove this functionality to avoid user deleting playlist by pressing delete key directly
#if false
            if (e.Key == Key.Delete && lb_PlaylistMenu.SelectedItems.Count == 1)
            {
                TrackListsViewModel trackListsVM = lb_PlaylistMenu.DataContext as TrackListsViewModel;
                Playlist            pl           = lb_PlaylistMenu.SelectedItem as Playlist;
                if (pl == null)
                {
                    throw new Exception("Failed to cast selected item to Playlist");
                }

                trackListsVM.RemovePlaylist(pl.GUID);
                lb_PlaylistMenu.SelectedIndex = trackListsVM.TrackLists.Count - 1;
                RefreshPlaylistContent();
            }
#endif
        }