Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 在模型中使用viewmodel属性,并将模型中更改的相同属性通知给viewmodel以绑定到视图_Wpf_Mvvm_Inotifypropertychanged - Fatal编程技术网

Wpf 在模型中使用viewmodel属性,并将模型中更改的相同属性通知给viewmodel以绑定到视图

Wpf 在模型中使用viewmodel属性,并将模型中更改的相同属性通知给viewmodel以绑定到视图,wpf,mvvm,inotifypropertychanged,Wpf,Mvvm,Inotifypropertychanged,SingleMessage.xaml的viewmodel为SingleMessageViewModel.cs,此viewmodel使用LogAcitvity类作为属性,并且viewmodel中定义的属性绑定到SingleMessage.xaml。 现在我想在SocketClient.cs(Model)中使用这个(viewmodel)属性,并通知viewmodel中的属性更改以更新视图 public class ViewModelBase : INotifyPropertyChanged {

SingleMessage.xaml的viewmodel为SingleMessageViewModel.cs,此viewmodel使用LogAcitvity类作为属性,并且viewmodel中定义的属性绑定到SingleMessage.xaml。 现在我想在SocketClient.cs(Model)中使用这个(viewmodel)属性,并通知viewmodel中的属性更改以更新视图

public class ViewModelBase : INotifyPropertyChanged
{
    public event PropertyChangedEventHandler PropertyChanged;

    public void NotifyPropertyChanged(string propertyName)
    {   
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}
其属性在viewmodel中使用的LogActivity类

public class LogActivity : ViewModelBase
{      
    private string messageLog;
    public string MessageLog
    {
        get { return messageLog; }
        set
        {
            if (value != messageLog)
            {
                messageLog = value;
                NotifyPropertyChanged("MessageLog");
            }
        }
    } 
}   
public LogActivity MessageLog
{
    get { return messagelog; }
    set
    {
        if (value != messagelog)
        {
            messagelog = value;
            NotifyPropertyChanged("MessageLog");
        }
    }
}  
这是我的viewmodel类

public class SingleMessageViewModel : ViewModelBase
{
    private LogActivity messagelog;

    public SingleMessageViewModel()
    {
        messagelog = new LogActivity();
    }   

    public LogActivity MessageLog
    {
        get { return messagelog; }
        set
        {
            if (value != messagelog)
            {
                messagelog = value;
                NotifyPropertyChanged("MessageLog");
            }
        }
    }  
 }
这是我的看法

<TextBox x:Name="TxtLog" Text="{Binding MessageLog.MessageLog, UpdateSourceTrigger=PropertyChanged}"  Grid.Row="1" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" />
我的模型是这样的

namespace PCSTESTGUI.Models
{   

public class SocketClient : INotifyPropertyChanged
{
    // Receive buffer.       
    byte[] dataBuffer = new byte[256];
    IAsyncResult result;
    public AsyncCallback pfnCallBack;
    public Socket clientSocket;
    private LogActivity messagelog;
    //private SingleMessageViewModel SingleMVM;
    int portNo;
    string ipAddress;
    string filePathName;
    string receivedResponse;
    string message = string.Empty;
    string connstring = ConfigurationManager.AppSettings["XmlConfigurationSetting"].ToString();
    string fileName = ConfigurationManager.AppSettings["XmlConfiguratonSettingFileName"].ToString();
    string messageTimeStamp = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString();

        public SocketClient()
        {
            messagelog = new LogActivity();
            SingleMessageViewModel SingleMVM = new SingleMessageViewModel(this);            
            //get the IPAddress and PortNo from save configuration setting
            filePathName = connstring + "\\" + fileName;
            try
            {
                if (File.Exists(filePathName))
                {
                    XDocument xdoc = XDocument.Load(filePathName);
                    var configsetting = from cs in xdoc.Descendants("ConfigurationSetting")
                                        select cs;
                    foreach (var config in configsetting)
                    {
                        ipAddress = config.Element("IPAddress").Value;
                        portNo = Convert.ToInt16(config.Element("PortNo").Value);
                    }
                    // check ipaddress and port no exists
                    if (ipAddress == "" || portNo == 0)
                    {
                        MessageBox.Show("IP Address and Port Number are required to connect to the Server\n", "Socket Connection : Missing", MessageBoxButton.OK, MessageBoxImage.Error);
                        FileLogger.Handle("Missing IP Address / Port Number in the configuration settings file");
                        MessageLog.MessageLog += messageTimeStamp + " : Missing IP Address / Port Number in the configuration settings file\n";
                        return;
                    }
                    //connect to the server
                    ConnectServer();
                }              
            }
            catch (Exception ex)
            {
                FileLogger.Handle(ex.Message);
                MessageLog.MessageLog += messageTimeStamp + " : " + ex.Message + "\n";

            }
        }
        public SingleMessageViewModel SingleMVM
        {
            get;
            set;
        }
        public LogActivity  MessageLog
        {
            get
            {
                return messagelog;
            }
            set
            {
                messagelog = value;
                this.SingleMVM.MessageLog = value;            
                NotifyPropertyChanged("MessageLog");              
            }
        }

        public void ConnectServer()
        { 
            try
            {   
                // Get the remote IP address
                IPAddress ip = IPAddress.Parse(ipAddress);
                int iPortNo = portNo;
                // Create the socket instance
                clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                FileLogger.Handle("StartConnect - Trying socket connection to PCS server '" + ip.ToString() + "' on Port " + iPortNo.ToString());
                MessageLog.MessageLog += messageTimeStamp + " : StartConnect - Trying socket connection to PCS server '" + ip.ToString() + "' on Port " + iPortNo.ToString() + "\n";

                // Create the end point 
                IPEndPoint ipEnd = new IPEndPoint(ip, iPortNo);
                // Connect to the remote host
                clientSocket.Connect(ipEnd);
                if (clientSocket.Connected)
                {
                    FileLogger.Handle("ProcessConnect - Client socket connected to PCS server '" + ip.ToString() + "' on Port " + iPortNo.ToString());
                    MessageLog.MessageLog += messageTimeStamp + " : ProcessConnect - Client socket connected to PCS server '" + ip.ToString() + "' on Port " + iPortNo.ToString() + "\n";

                    //Wait for data asynchronously 
                    WaitForData();
                }
                else
                {
                    ConnectServer();
                }
            }
            catch (SocketException ex)
            {
                FileLogger.Handle(ex.Message);
                MessageLog.MessageLog += messageTimeStamp + " : " + ex.Message + "\n";
            }
        }

        public void SendMessage(string message)
        {
            try
            {                
                if (!clientSocket.Connected)
                    ConnectServer();

                if (message != "")
                {
                    this.message = message + "\r\n";
                    byte[] byteMessage = Encoding.ASCII.GetBytes(this.message);
                    //NetworkStream networkStream = new NetworkStream(clientSocket);
                    //StreamWriter streamWriter = new StreamWriter(networkStream);
                    //streamWriter.WriteLine(byteMessage);
                    //streamWriter.Flush();
                    if (clientSocket != null && clientSocket.Connected)
                    {
                        FileLogger.Handle("Pseudo Command message processing tasks started");
                        FileLogger.Handle(" -> " + message.ToUpper());
                        MessageLog.MessageLog += messageTimeStamp + " : Pseudo Command message processing tasks started\n";
                        MessageLog.MessageLog += messageTimeStamp + " : -> " + message.ToUpper() + "\n";
                        clientSocket.Send(byteMessage);
                    }
                    else
                    {
                        ConnectServer();
                        if (clientSocket.Connected)
                        {
                            FileLogger.Handle("Pseudo Command message processing tasks started");
                            FileLogger.Handle(" -> " + message.ToUpper());
                            MessageLog.MessageLog += messageTimeStamp + " : Pseudo Command message processing tasks started\n";
                            MessageLog.MessageLog += messageTimeStamp + " : -> " + message.ToUpper() + "\n";
                            clientSocket.Send(byteMessage);
                        }
                    }
                }              
            }
            catch (Exception ex)
            {
                FileLogger.Handle(ex.Message);
                MessageLog.MessageLog += messageTimeStamp + " : " + ex.Message + "\n";
            }
        }

        public void DissconnectServer()
        {   
            clientSocket.Close();
            clientSocket = null;
            FileLogger.Handle("CloseConnection - Closed socket connection to PCS server '" + ipAddress + "' on Port " + portNo.ToString());
            MessageLog.MessageLog += messageTimeStamp + " : ProcessConnect - Client socket connected to PCS server '" + ipAddress + "' on Port " + portNo.ToString() + "\n";
        }

        public class SocketPacket
        {
            public System.Net.Sockets.Socket thisSocket;
            public byte[] dataBuffer = new byte[1024];
        }

        public void WaitForData()
        {
            try
            {
                if (pfnCallBack == null)
                {
                    pfnCallBack = new AsyncCallback(OnDataReceived);
                }
                SocketPacket theSocPkt = new SocketPacket();
                theSocPkt.thisSocket = clientSocket;
                // Start listening to the data asynchronously
                result = clientSocket.BeginReceive(theSocPkt.dataBuffer, 0, theSocPkt.dataBuffer.Length,
                                                      SocketFlags.None, pfnCallBack, theSocPkt);

                if (result.IsCompleted == false)
                {
                    Console.Write(".");
                }

            }
            catch (SocketException se)
            {
                FileLogger.Handle(se.Message);
                MessageLog.MessageLog += messageTimeStamp + " : " + se.Message + "\n";
            }
        }

        public void OnDataReceived(IAsyncResult asyn)
        {
            try
            {               
                SocketPacket theSockId = (SocketPacket)asyn.AsyncState;
                int iRx = theSockId.thisSocket.EndReceive(asyn);
                char[] chars = new char[iRx + 1];
                System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
                int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
                System.String szData = new System.String(chars);
                receivedResponse = receivedResponse + szData + "\n";
                if (szData.ToString() != "\0" || szData.ToString() != "")
                {
                    FileLogger.Handle(" <- " + szData.Replace("\n\0", ""));

                    App.Current.Dispatcher.BeginInvoke((Action)delegate
                    {
                        MessageLog.MessageLog += messageTimeStamp + " : <- " + szData.Replace("\n\0", "") + "\n";
                        if (SingleMVM == null)
                            SingleMVM = new SingleMessageViewModel(this);
                        //this.SingleMVM.MessageLog.MessageLog += this.MessageLog.MessageLog;
                        this.SingleMVM.updateMesssage(szData.Replace("\n\0", ""));
                    });

                } 

                WaitForData();
            }
            catch (ObjectDisposedException ex)
            {                
                FileLogger.Handle(ex.Message);
                MessageLog.MessageLog += messageTimeStamp + " : " + ex.Message + "\n";               
            }
            catch (SocketException se)
            {
                FileLogger.Handle(se.Message);
                MessageLog.MessageLog += messageTimeStamp + " : " + se.Message + "\n";               
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
名称空间PCSTESTGUI.Models
{   
公共类SocketClient:INotifyPropertyChanged
{
//接收缓冲区。
字节[]数据缓冲=新字节[256];
IAsyncResult结果;
公共电话号码:pfnCallBack;
公共套接字clientSocket;
私有日志活动消息日志;
//私有SingleMessageViewModel SingleMVM;
国际港口;
字符串地址;
字符串文件路径名;
字符串接收响应;
string message=string.Empty;
string connstring=ConfigurationManager.AppSettings[“XmlConfigurationSetting”].ToString();
字符串文件名=ConfigurationManager.AppSettings[“XmlConfigurationSettingFileName”].ToString();
string messageTimeStamp=DateTime.Now.ToSortDateString()+“”+DateTime.Now.ToLongTimeString();
公共SocketClient()
{
messagelog=新的日志活动();
SingleMessageViewModel SingleMVM=新的SingleMessageViewModel(此);
//从保存配置设置中获取IPAddress和PortNo
filePathName=connstring+“\\”+文件名;
尝试
{
if(File.Exists(filePathName))
{
XDocument xdoc=XDocument.Load(文件路径名);
var configsetting=来自xdoc.subjects中的cs(“ConfigurationSetting”)
选择cs;
foreach(配置设置中的变量配置)
{
ipAddress=config.Element(“ipAddress”).Value;
portNo=Convert.ToInt16(config.Element(“portNo”).Value);
}
//检查IP地址和端口是否不存在
如果(ipAddress==“”| |端口号==0)
{
MessageBox.Show(“连接到服务器需要IP地址和端口号\n”,“套接字连接:缺少”,MessageBoxButton.OK,MessageBoxImage.Error);
Handle(“配置设置文件中缺少IP地址/端口号”);
MessageLog.MessageLog+=messageTimeStamp+“:配置设置文件中缺少IP地址/端口号\n”;
返回;
}
//连接到服务器
ConnectServer();
}              
}
捕获(例外情况除外)
{
FileLogger.Handle(例如消息);
MessageLog.MessageLog+=messageTimeStamp+“:”+ex.Message+“\n”;
}
}
公共SingleMessageViewModel SingleMVM
{
得到;
设置
}
公共日志活动消息日志
{
得到
{
返回消息日志;
}
设置
{
messagelog=值;
this.SingleMVM.MessageLog=值;
NotifyPropertyChanged(“MessageLog”);
}
}
公共连接服务器()
{ 
尝试
{   
//获取远程IP地址
IPAddress ip=IPAddress.Parse(IPAddress);
int iPortNo=端口号;
//创建套接字实例
clientSocket=新套接字(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
Handle(“StartConnection-尝试与PC服务器的套接字连接”“+ip.ToString()+”,位于端口“+iPortNo.ToString()”);
MessageLog.MessageLog+=messageTimeStamp+“:StartConnection-在端口“+iPortNo.ToString()+”\n”上尝试与PC服务器“+ip.ToString()+””的套接字连接;
//创建端点
IPEndPoint ipEnd=新的IPEndPoint(ip,iPortNo);
//连接到远程主机
clientSocket.Connect(ipEnd);
if(clientSocket.Connected)
{
Handle(“ProcessConnect-连接到PC服务器的客户端套接字””+ip.ToString()+“+iPortNo.ToString()端口上的””);
MessageLog.MessageLog+=messageTimeStamp+“:ProcessConnect-连接到PC服务器的客户端套接字“+ip.ToString()+”,端口“+iPortNo.ToString()+”\n”;
//异步等待数据
WaitForData();
}
其他的
{
ConnectServer();
}
}
捕获(SocketException例外)
{
FileLogger.Handle(例如消息);
MessageLog.MessageLog+=messageTimeStamp+“:”+ex.Message+“\n”;
}
}
公共无效发送消息(字符串消息)
{
尝试
{                
如果(!clientSocket.Connected)
ConnectServer();
如果(消息!=“”)
{
this.message=message+“\r\n”;
byte[]byteMessage=Encoding.ASCII.GetBytes(this.message);
//NetworkStream NetworkStream=新的NetworkStream(clientSocket);
//StreamWriter StreamWriter=新StreamWriter(网络流);
//streamWriter.WriteLine(byteMessage);
namespace PCSTESTGUI.Models
{   

public class SocketClient : INotifyPropertyChanged
{
    // Receive buffer.       
    byte[] dataBuffer = new byte[256];
    IAsyncResult result;
    public AsyncCallback pfnCallBack;
    public Socket clientSocket;
    private LogActivity messagelog;
    //private SingleMessageViewModel SingleMVM;
    int portNo;
    string ipAddress;
    string filePathName;
    string receivedResponse;
    string message = string.Empty;
    string connstring = ConfigurationManager.AppSettings["XmlConfigurationSetting"].ToString();
    string fileName = ConfigurationManager.AppSettings["XmlConfiguratonSettingFileName"].ToString();
    string messageTimeStamp = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString();

        public SocketClient()
        {
            messagelog = new LogActivity();
            SingleMessageViewModel SingleMVM = new SingleMessageViewModel(this);            
            //get the IPAddress and PortNo from save configuration setting
            filePathName = connstring + "\\" + fileName;
            try
            {
                if (File.Exists(filePathName))
                {
                    XDocument xdoc = XDocument.Load(filePathName);
                    var configsetting = from cs in xdoc.Descendants("ConfigurationSetting")
                                        select cs;
                    foreach (var config in configsetting)
                    {
                        ipAddress = config.Element("IPAddress").Value;
                        portNo = Convert.ToInt16(config.Element("PortNo").Value);
                    }
                    // check ipaddress and port no exists
                    if (ipAddress == "" || portNo == 0)
                    {
                        MessageBox.Show("IP Address and Port Number are required to connect to the Server\n", "Socket Connection : Missing", MessageBoxButton.OK, MessageBoxImage.Error);
                        FileLogger.Handle("Missing IP Address / Port Number in the configuration settings file");
                        MessageLog.MessageLog += messageTimeStamp + " : Missing IP Address / Port Number in the configuration settings file\n";
                        return;
                    }
                    //connect to the server
                    ConnectServer();
                }              
            }
            catch (Exception ex)
            {
                FileLogger.Handle(ex.Message);
                MessageLog.MessageLog += messageTimeStamp + " : " + ex.Message + "\n";

            }
        }
        public SingleMessageViewModel SingleMVM
        {
            get;
            set;
        }
        public LogActivity  MessageLog
        {
            get
            {
                return messagelog;
            }
            set
            {
                messagelog = value;
                this.SingleMVM.MessageLog = value;            
                NotifyPropertyChanged("MessageLog");              
            }
        }

        public void ConnectServer()
        { 
            try
            {   
                // Get the remote IP address
                IPAddress ip = IPAddress.Parse(ipAddress);
                int iPortNo = portNo;
                // Create the socket instance
                clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                FileLogger.Handle("StartConnect - Trying socket connection to PCS server '" + ip.ToString() + "' on Port " + iPortNo.ToString());
                MessageLog.MessageLog += messageTimeStamp + " : StartConnect - Trying socket connection to PCS server '" + ip.ToString() + "' on Port " + iPortNo.ToString() + "\n";

                // Create the end point 
                IPEndPoint ipEnd = new IPEndPoint(ip, iPortNo);
                // Connect to the remote host
                clientSocket.Connect(ipEnd);
                if (clientSocket.Connected)
                {
                    FileLogger.Handle("ProcessConnect - Client socket connected to PCS server '" + ip.ToString() + "' on Port " + iPortNo.ToString());
                    MessageLog.MessageLog += messageTimeStamp + " : ProcessConnect - Client socket connected to PCS server '" + ip.ToString() + "' on Port " + iPortNo.ToString() + "\n";

                    //Wait for data asynchronously 
                    WaitForData();
                }
                else
                {
                    ConnectServer();
                }
            }
            catch (SocketException ex)
            {
                FileLogger.Handle(ex.Message);
                MessageLog.MessageLog += messageTimeStamp + " : " + ex.Message + "\n";
            }
        }

        public void SendMessage(string message)
        {
            try
            {                
                if (!clientSocket.Connected)
                    ConnectServer();

                if (message != "")
                {
                    this.message = message + "\r\n";
                    byte[] byteMessage = Encoding.ASCII.GetBytes(this.message);
                    //NetworkStream networkStream = new NetworkStream(clientSocket);
                    //StreamWriter streamWriter = new StreamWriter(networkStream);
                    //streamWriter.WriteLine(byteMessage);
                    //streamWriter.Flush();
                    if (clientSocket != null && clientSocket.Connected)
                    {
                        FileLogger.Handle("Pseudo Command message processing tasks started");
                        FileLogger.Handle(" -> " + message.ToUpper());
                        MessageLog.MessageLog += messageTimeStamp + " : Pseudo Command message processing tasks started\n";
                        MessageLog.MessageLog += messageTimeStamp + " : -> " + message.ToUpper() + "\n";
                        clientSocket.Send(byteMessage);
                    }
                    else
                    {
                        ConnectServer();
                        if (clientSocket.Connected)
                        {
                            FileLogger.Handle("Pseudo Command message processing tasks started");
                            FileLogger.Handle(" -> " + message.ToUpper());
                            MessageLog.MessageLog += messageTimeStamp + " : Pseudo Command message processing tasks started\n";
                            MessageLog.MessageLog += messageTimeStamp + " : -> " + message.ToUpper() + "\n";
                            clientSocket.Send(byteMessage);
                        }
                    }
                }              
            }
            catch (Exception ex)
            {
                FileLogger.Handle(ex.Message);
                MessageLog.MessageLog += messageTimeStamp + " : " + ex.Message + "\n";
            }
        }

        public void DissconnectServer()
        {   
            clientSocket.Close();
            clientSocket = null;
            FileLogger.Handle("CloseConnection - Closed socket connection to PCS server '" + ipAddress + "' on Port " + portNo.ToString());
            MessageLog.MessageLog += messageTimeStamp + " : ProcessConnect - Client socket connected to PCS server '" + ipAddress + "' on Port " + portNo.ToString() + "\n";
        }

        public class SocketPacket
        {
            public System.Net.Sockets.Socket thisSocket;
            public byte[] dataBuffer = new byte[1024];
        }

        public void WaitForData()
        {
            try
            {
                if (pfnCallBack == null)
                {
                    pfnCallBack = new AsyncCallback(OnDataReceived);
                }
                SocketPacket theSocPkt = new SocketPacket();
                theSocPkt.thisSocket = clientSocket;
                // Start listening to the data asynchronously
                result = clientSocket.BeginReceive(theSocPkt.dataBuffer, 0, theSocPkt.dataBuffer.Length,
                                                      SocketFlags.None, pfnCallBack, theSocPkt);

                if (result.IsCompleted == false)
                {
                    Console.Write(".");
                }

            }
            catch (SocketException se)
            {
                FileLogger.Handle(se.Message);
                MessageLog.MessageLog += messageTimeStamp + " : " + se.Message + "\n";
            }
        }

        public void OnDataReceived(IAsyncResult asyn)
        {
            try
            {               
                SocketPacket theSockId = (SocketPacket)asyn.AsyncState;
                int iRx = theSockId.thisSocket.EndReceive(asyn);
                char[] chars = new char[iRx + 1];
                System.Text.Decoder d = System.Text.Encoding.UTF8.GetDecoder();
                int charLen = d.GetChars(theSockId.dataBuffer, 0, iRx, chars, 0);
                System.String szData = new System.String(chars);
                receivedResponse = receivedResponse + szData + "\n";
                if (szData.ToString() != "\0" || szData.ToString() != "")
                {
                    FileLogger.Handle(" <- " + szData.Replace("\n\0", ""));

                    App.Current.Dispatcher.BeginInvoke((Action)delegate
                    {
                        MessageLog.MessageLog += messageTimeStamp + " : <- " + szData.Replace("\n\0", "") + "\n";
                        if (SingleMVM == null)
                            SingleMVM = new SingleMessageViewModel(this);
                        //this.SingleMVM.MessageLog.MessageLog += this.MessageLog.MessageLog;
                        this.SingleMVM.updateMesssage(szData.Replace("\n\0", ""));
                    });

                } 

                WaitForData();
            }
            catch (ObjectDisposedException ex)
            {                
                FileLogger.Handle(ex.Message);
                MessageLog.MessageLog += messageTimeStamp + " : " + ex.Message + "\n";               
            }
            catch (SocketException se)
            {
                FileLogger.Handle(se.Message);
                MessageLog.MessageLog += messageTimeStamp + " : " + se.Message + "\n";               
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
public void updateMesssage(string message)
{            
    App.Current.Dispatcher.BeginInvoke(DispatcherPriority.DataBind, new Action(() =>
    {
        this.MessageLog.MessageLog += messageTimeStamp + " : <- " + message + "\n";
    }));
}