示例#1
0
        private void OnEditClick(object sender, RoutedEventArgs e)
        {
            int index = ListBox.SelectedIndex;

            if (index < 0)
            {
                MessageBox.Show("You must select an item to edit",
                                "Selection Error", MessageBoxButton.OK,
                                MessageBoxImage.Warning);
                return;
            }

            string itemToEdit = data[index];

            var dlg = new StringEditor
            {
                IsNew = false, Owner = this, PathString = itemToEdit
            };

            bool okay = dlg.ShowDialog().GetValueOrDefault();

            if (!okay)
            {
                return;
            }

            data[index] = dlg.PathString;
        }
示例#2
0
        private void OnAddClick(object sender, RoutedEventArgs e)
        {
            var dlg = new StringEditor {
                IsNew = true, Owner = this
            };
            bool okay = dlg.ShowDialog().GetValueOrDefault();

            if (!okay)
            {
                return;
            }

            data.Add(dlg.PathString);
        }