private void PortNameComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { //BText.Text = PortNameComboBox.SelectedItem.ToString() + "串口被选择"; var selection = PortNameComboBox.SelectedItem; DeviceListEntry entry = (DeviceListEntry)selection; TipText.Text = entry.InstancePortName + "已选择"; selectPortName = entry.InstancePortName; }
/// <summary> /// Update Available Serial Port to UI List /// 更新可选的串口到UI列表中 /// </summary> /// <param name="deviceInfo">DeviceInformation Type</param> private void AddDeviceToList(DeviceInformation deviceInformation, string deviceSelector) { var match = FindDevice(deviceInformation.Id); if (match == null) { match = new DeviceListEntry(deviceInformation, deviceSelector); listOfDevice.Add(match); serialPortDeviceDic[deviceInformation.Name] = deviceInformation.Id; } }