private void Grid_Loaded(object sender, RoutedEventArgs e) { try { cbPorts.ItemsSource = ComPort.GetAllNamesPort(); cbPorts.SelectedIndex = 0; currentPort = new ComPort(cbPorts.SelectedValue.ToString()); } catch (Exception) { MessageBox.Show("Отсутствуют доступные COM порты"); } }
private void cbPorts_DropDownOpened(object sender, EventArgs e) { cbPorts.ItemsSource = ComPort.GetAllNamesPort(); }