I am using MVVM pattern. I want to use datagrid's refresh method . I have also gone through following link and its useful: How to refresh a WPF DataGrid?
but my problem is : I have created one datagrid object in viewmodel like this:
public DataGrid ActiveGrid=new DataGrid();
public void RefreshGrid()
{
View.Dispatcher.Invoke((Action)(() =>
ActiveGrid.Items.Refresh()
));
}
and my datagrid's itemsource is already bound to another collection e.g
<DataGrid x:Name="ActiveGrid"
IsReadOnly="True"
ItemsSource="{Binding ActiveCallCollection}"
SelectedItem="{Binding ActiveGridCollection,
Mode=TwoWay}" SelectionMode="Single"
Visibility="{Binding IsActiveCallsSelected,
Converter={StaticResource BooleanToVisibilityConverter}}"
d:LayoutOverrides="Height">
How can I bind ActiveGrid to xaml datagrid.
<ContentPresenter Content="{Binding ActiveGrid}" >
but I think thats not the correct option here. If you are created a NEW observable collection after the constructor you do need to NotifyPropertyChanged the collection. – Rik van den Berg