private void OnOk(object sender, RoutedEventArgs e) { if (ProcessList.SelectedIndex == -1) { MessageBox.Show("Select target app"); return; } SelectedProcess = ProcessList.SelectedItem as ProcessVm; Debug.Assert(SelectedProcess != null); DialogResult = true; Close(); }
private void UpdateView() { Processes = new List <ProcessVm>(); foreach (Process p in Process.GetProcesses()) { if (p.MainWindowHandle != IntPtr.Zero) { var vm = new ProcessVm { Process = p }; Processes.Add(vm); } } Processes = Processes.OrderBy(p => p.Process.ProcessName).ToList(); DataContext = Processes; }