I’m starting to creat this project using MVVM Model. But I have no idea how can I implementing it using a toolbar.
I need a little of help. This is the site web which I’m watching:
http://msdn.microsoft.com/en-us/library/system.io.ports.serialport.aspx
I think the last one would be the model, I’m not sure if I’m doing fine:
public class Port : INotifyPropertyChanged, IDataErrorInfo
{
private SerialPort _serialPort;
public Port()
{
_serialPort = new SerialPort();
}
public string PortName
{
get { return _serialPort.PortName; }
set
{
_serialPort.PortName = value;
OnPropertyChanged("PortName");
}
}
public int BaudRate
{
get { return _serialPort.BaudRate; }
set
{
_serialPort.BaudRate = value;
OnPropertyChanged("BaudRate");
}
}
public Parity Parity
{
get { return _serialPort.Parity; }
set
{
_serialPort.Parity = value;
OnPropertyChanged("Parity");
}
}
public int DataBits
{
get { return _serialPort.DataBits; }
set
{
_serialPort.DataBits = value;
OnPropertyChanged("PortDataBits");
}
}
public StopBits StopBits
{
get { return _serialPort.StopBits; }
set
{
_serialPort.StopBits = value;
OnPropertyChanged("PortStopBits");
}
}
public Handshake Handshake
{
get { return _serialPort.Handshake; }
set
{
_serialPort.Handshake = value;
OnPropertyChanged("PortHandshake");
}
}
public string[] AvailablePortNames
{
get { return SerialPort.GetPortNames(); }
}
#region IDataErrorInfo Members
string IDataErrorInfo.Error { get { return null; } }
string IDataErrorInfo.this[string propertyName]
{
get { return this.GetValidationError(propertyName); }
}
The program consists that the user must set and configure and open it. I need a little of help about how can I implement it using this model. Thanks a lot.

You will need a ViewModel that contains 1 SerialPort and a few Lists for baudrates, parity-options etc.
You can then use a ComboBox, bind the ItemsSource to the list and the SelectedItem to a SerialPort property.