Relative Content

Tag Archive for c#wpfmvvm

Datagrid won’t get updated when changed from ViewModel

I have a DataGrid where its ItemsSource bound to a DataTable. When I Update the DataTable, the data from the ViewModel gets updated but the UI won’t. I already use INotifyPropertyChanged for my ViewModel.
Here is my functions

Best practice about UI component handle in MVVM patern

I’m developing a WPF application with MVVM pattern and I was wondering how can I open and close a window or a dialog from ViewModel or even this is a best practice or not? I mean when it comes to MVVM pattern is always said to avoid code-behind as much as possible so I was thinking should I open and close windows from code-behind or it is OK to do it from the ViewModel. one of the approaches is mentioned is the following one: