Entity Framework & Binding syncronisation
- by Jefim
* EDIT *
Sorry, I should make it clearer.
Imagine I have an entity:
public class MyObject
{
public string Name { get; set; }
}
And I have a ListBox:
<ListBox x:Name="lbParts">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
I bind it to a collection in code-behind:
ObjectQuery<MyObject> componentQuery = context.MyObjectSet;
Binding b = new Binding();
b.Source = componentQuery;
lbParts.SetBinding(ListBox.ItemsSourceProperty, b);
And the on a button click I add an entity to the MyObjectSet:
var myObject = new MyObject { Name = "Test" };
context.AddToMyObjectSet(myObject);
Here is the problem - this object needs to update in the UI to. But it is not added there :(
Help!