Quantcast
Channel: How can i refresh my DataGrid on WPF - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How can i refresh my DataGrid on WPF

$
0
0

I have a problem.

I have this WPF GridView

<DataGrid   ItemsSource="{Binding Path=myOrder.Detail}"></DataGrid>

My property on the viewModel looks like this:

public myOrderModel myOrder { get; set; }

and this is my model:

public partial class myOrderModel{    public int ID_Order { get; set; }    public List<myOrdenDetail> Detail { get; set; }}

On the constructor of the viewmodel y fill my Order with data from a WCF service and the detail is show on the grid correctly (of course this code is simplified). Now I need to modify de Detail collection (add, remove or modify) from inside the viewmodel. The problem is that the gridview is not refreshed to show this changes.

How can i notify the grid to reflect the changes inside Detail List?Thanks!!!!

EDIT

As suggested i try with ObservableCollection and it worked. In the viewModel I add a property:

public ObservableCollection<myOrdenDetail> Detail{ get; set; }

and Map the model to my new property:

Detail = new ObservableCollection<myOrdenDetail>(myOrder.Detail);

Of course i need to map Detail back to the original model when I save the information. I could also change the original model behind WCF service but i don't know how would WCF react with ObservableCollection.

Thanks!


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>
<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596344.js" async> </script>