Hi.
I am developing an WPF application that connect to a sql server database by EntityFramework . I have a table in my database named Tasks .I have a Treeview control in my wpf application that is bound to my Task entity in EntityFramework model .
First I bound TreeView to Task entity using this code .
MyEntity myEntity = new MyEntity();
myTreeView.ItemsSource = myEntity.Tasks;
I Then did add operation using this code:
Task t = new Task();
t.ID = 10;
t.Title = "Task1";
myEntity.Tasks.Add(t);
myEntity.SaveChanges();
I noticed that this code updated my database but did not update UI automatically until I restart my application . Then I used this code to overcome this problem :
IBindingList _bindingList;
_bindingList = ((IListSource)myEntity.Tasks).GetList() As IBindingList;
myTreeView.ItemsSource = _bindingList;
Now When I add a Task it works (It updates UI):
t.ID = 10;
t.Title = "Task1"
_bindingList.Add(t);
myEntity.SaveChanges();
My problem is here . This application has been used by two persons on two computers in our local network . When person1 add a task it does not update UI in person2 application . I Have tried Mode = TwoWay in xaml but this did'nt change anything .
How can I reflect changes in my application UI in computer 1 whenever a change is applied in my Database by computer 2?
Sorry for my too long question and thanks for your answers.