0

我有一个组合框,我绑定了可用的端口名称:

<ObjectDataProvider ObjectType="{x:Type ports:SerialPort}" MethodName="GetPortNames" x:Key="portNames"/>

           <ComboBox Grid.Row="0" Grid.Column="1" Height="21" ItemsSource="{Binding Source={StaticResource portNames}}" SelectedItem="{Binding Source={x:Static ConnectionMngr.Instance}, Path=PortSettings.PortName, Mode=TwoWay}" VerticalContentAlignment="Center"/>

如果在连接 COM 时打开窗口,我会在组合框中看到端口名称值。

如果我在未连接 COM 时打开窗口,我看不到组合框中的值,但我希望当我连接 COM 时该值会在那里。

连接 COM 以查看值时,如何导致引用组合框?

谢谢

4

1 回答 1

0

在用作绑定到的实例的类中,实现 INotifyPropertyChanged 并在要更新的属性中引发它

public string PortName 
{ 
    get { return __portName;}
    set
      {
          if_portName == value) return;
          _portName = value;
          RaisePropertyChanged("PortName");
      }
  }
于 2013-06-12T15:22:37.970 回答