I'm retriving the serialports and populate a combobox as this:
XAML
<ComboBox Grid.Row="7" Grid.Column="2" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding ComPorts, Mode = TwoWay,UpdateSourceTrigger=PropertyChanged}" SelectedValue="{Binding Path= myserialportx, Mode = TwoWay,UpdateSourceTrigger=PropertyChanged}" SelectedValuePath="myserialportx"/>
VM
Private _comports As String()
Public Property ComPorts() As String()
Get
Return System.IO.Ports.SerialPort.GetPortNames()
End Get
Set(ByVal value As String())
_comports = System.IO.Ports.SerialPort.GetPortNames()
SetAndNotify(_comports, value)
End Set
End Property
Private _myserialportx As String
Public Property myserialportx As String
Get
Return _myserialportx
End Get
Set(ByVal value As String)
My.Settings.comport = value
SetAndNotify(_myserialportx, value)
End Set
End Property
I need to save the selected port in my.setting so user does not need to set it anytime, and then I would like to also "preselect" it as it can see what port is actually selected. Any advice?
I figured it out. Seem that when in debug VS save setting in a file that is not the same you see in the editor, switching to release mode it actually work.