Beispiel #1
0
 private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs args)
 {
     Debug.Print("Item " + args.SelectedIndex + " was selected.");
 }
Beispiel #2
0
        private void OnItemSelected(object sender, SelectionChangedEventArgs e)
        {
            ListViewItem selectedItem = ((ListView)sender).SelectedItem;

            // If this is a double-tap on a directory, change the current directory to the selection.
            if ((selectedItem != null) &&
                (selectedItem.SubItems.Count > 0) &&
                (e.SelectedIndex == e.PreviousSelectedIndex))
            {
                string directoryName = ((ListViewSubItem)selectedItem.SubItems[0]).Text;
                directoryName = directoryName.Substring(1, directoryName.Length - 2);

                // Check for special ".." name.
                if (directoryName == "..")
                {
                    directoryName = Directory.GetCurrentDirectory();
                    directoryName = Path.GetDirectoryName(directoryName);
                }

                // If the directory exists...
                if (Directory.Exists(directoryName))
                {
                    // Set the current directory.
                    Directory.SetCurrentDirectory(directoryName);

                    // Refresh the list.
                    RefreshList();
                }
            }
        }