Witajcie,

mam problem z odświeżeniem DataGrid. Mój kod:

private AutoLotEntities _autoLot = null;

private void MainWindowAutoLot_Loaded(object sender, RoutedEventArgs e)
{
  _autoLot = new AutoLotEntities()
  
  var query = _autoLot.KALENDARZ.ToList().Select(p => new
  {
      Start = p.DATA_START.ToString("HH:mm"),
      Opis = p.OPIS
  }).Take(5);
 
  DataGrid1.ItemsSource = query;

  var upd = new DispatcherTimer(new TimeSpan(0, 0, 60),
      DispatcherPriority.Background,
      delegate
      {
          RefreshDataGrid();
      }, Dispatcher);  
}

private void RefreshDataGrid()
{
  var query = _autoLot.KALENDARZ.ToList().Select(p => new
  {
      Start = p.DATA_START.ToString("HH:mm"),
      Opis = p.OPIS
  }).Take(5);

  DataGrid1.ItemsSource = query;
}

oraz DataGrid:

<DataGrid x:Name="DataGrid1" AutoGenerateColumns="False" RowBackground="#FF3F5DAE" AlternatingRowBackground="#FF1A7DB6">
    <DataGrid.Columns>
        <DataGridTextColumn Binding="{Binding Start}" Foreground="#FFFFFFFF" Header="Start" CanUserResize="False" Width="*"/>
        <DataGridTextColumn Binding="{Binding Opis}" Foreground="#FFFFFFFF" Header="Opis" CanUserResize="False" Width="*"/>
    </DataGrid.Columns>
</DataGrid>

Chciałam uzyskać efekt odświeżenia - co 60s. - tego co jest wyświetlane w DataGrid. Niestety w żaden sposób mi nie wychodzi. Próbowałam w RefreshDataGrid() dać DataGrid1.Items.Refresh() czy najpierw DataGrid1.ItemSource = "" i dopiero DataGrid1.ItemsSource = query, ale niestety nie działa. Proszę o wskazówki co powinnam zrobić, żeby działało tak jak opisałam wyżej.

Pozdrawiam
Zuza

dodanie znaczników `` - fp