This question is locked. New answers and comments are not allowed.
Hello
In the example below i have simple DateTemplate used to display a customer and it's orders. Every OrderRow have Button with a DeleteCommand used to delete the order from the database.
I am having problems to get the ListBox with orders to reflect the changes made. If i execute the command the orderrow is deleted from the database but it is not reflected in the ListBox.
If i implement this with EntityFramework the changes are reflected in the GUI.
How can i solve this issue?
In the example below i have simple DateTemplate used to display a customer and it's orders. Every OrderRow have Button with a DeleteCommand used to delete the order from the database.
I am having problems to get the ListBox with orders to reflect the changes made. If i execute the command the orderrow is deleted from the database but it is not reflected in the ListBox.
If i implement this with EntityFramework the changes are reflected in the GUI.
How can i solve this issue?
<Grid DataContext="{StaticResource vm}"> <ListBox ItemsSource="{Binding VIEW_CUSTOMERS.View}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <Label Content="{Binding CustomerNumber}"/> <Label Content="{Binding CustomerName}"/> <ListBox ItemsSource="{Binding ORDERs}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <Label Content="{Binding OrderNumber}"/> <Label Content="{Binding OrderDate}"/> <Button Content="Remove" Command="{Binding Cmd, Source={StaticResource vm}}" CommandParameter="{Binding}"/> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </StackPanel> </DataTemplate> </ListBox.ItemTemplate> </ListBox></Grid>//////////////////////////////////////Implementation of DeleteCommand//public ICommand Cmd { get; set; }private void Cmd_Execute(object parameter){ var order = parameter as ORDER; if (order != null) { order.CUSTOMER.ORDERs.Remove(order); this.Context.Delete(order); this.Context.SaveChanges(); }}private bool Cmd_CanExecute(object parameter){ return true;}