title: Dynamic datagrid View Updation
body: <p>Hey Everyone I am new in WPF trying to learn few things.
  In dataGrid My grid is not getting updated when I update my dataList
  my XAML is:</p>
  
  <pre><code>&lt;Window x:Class="DataGrid.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib" 
          xmlns:l="clr-namespace:DataGrid" Title="MainWindow" Height="350" Width="525"&gt;
      &lt;Window.Resources&gt;
          &lt;ObjectDataProvider x:Key="selectionUnits" 
                          MethodName="GetNames" ObjectType="{x:Type System:Enum}"&gt;
              &lt;ObjectDataProvider.MethodParameters&gt;
                  &lt;x:Type TypeName="DataGridSelectionUnit" /&gt;
              &lt;/ObjectDataProvider.MethodParameters&gt;
          &lt;/ObjectDataProvider&gt;
          &lt;ObjectDataProvider x:Key="selectionModes" 
                          MethodName="GetNames" ObjectType="{x:Type System:Enum}"&gt;
              &lt;ObjectDataProvider.MethodParameters&gt;
                  &lt;x:Type TypeName="DataGridSelectionMode" /&gt;
              &lt;/ObjectDataProvider.MethodParameters&gt;
          &lt;/ObjectDataProvider&gt;
          &lt;ObjectDataProvider x:Key="headersVisibility" 
                          MethodName="GetNames" ObjectType="{x:Type System:Enum}"&gt;
              &lt;ObjectDataProvider.MethodParameters&gt;
                  &lt;x:Type TypeName="DataGridHeadersVisibility" /&gt;
              &lt;/ObjectDataProvider.MethodParameters&gt;
          &lt;/ObjectDataProvider&gt;
          &lt;l:GenderTemplateSelector x:Key="genderTemplateSelector"&gt;
              &lt;l:GenderTemplateSelector.MaleTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Grid Background="LightBlue"&gt;
                          &lt;Image Source="{Binding Image}" Width="50" /&gt;
                      &lt;/Grid&gt;
                  &lt;/DataTemplate&gt;
              &lt;/l:GenderTemplateSelector.MaleTemplate&gt;
              &lt;l:GenderTemplateSelector.FemaleTemplate&gt;
                  &lt;DataTemplate&gt;
                      &lt;Grid Background="Salmon"&gt;
                          &lt;Image Source="{Binding Image}" Width="50" /&gt;
                      &lt;/Grid&gt;
                  &lt;/DataTemplate&gt;
              &lt;/l:GenderTemplateSelector.FemaleTemplate&gt;
          &lt;/l:GenderTemplateSelector&gt;
      &lt;/Window.Resources&gt;
      &lt;Grid&gt;
          &lt;TabControl TabStripPlacement="Left"&gt;
              &lt;TabItem Header="Auto Column Generation"&gt;
                  &lt;DataGrid ItemsSource="{Binding Customers}" /&gt;
              &lt;/TabItem&gt;
  
          &lt;/TabControl&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>my xaml.cs file is :</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      public MainWindow()
      {
         InitializeComponent();
         DataContext = new MainWindowViewModel();
      }
  }
  
   public class MainWindowViewModel
      {
          public ICollectionView Customers { get; private set; }
          public ICollectionView GroupedCustomers { get; private set; }
  
  
      public MainWindowViewModel()
      {
          var timer = new System.Timers.Timer();
  
          timer.Elapsed += timer_Tick;
          timer.Interval = 20000;
          timer.Enabled = true;
          timer.Start();
          AddServices();
  
  
  
      }
      void timer_Tick(object sender, EventArgs e)
      {
          AddServicesTimer();
      }
      public void AddServicesTimer()
      {
  
          var _customers = new List&lt;Customer&gt;();
          for(int i = 0; i &lt; 5; i++)
          {
             var c = new Customer
              {
                  FirstName = "Christian",
                  Name = "SrvNameTimer",
                  State = "SrvState",
                  LastName = "Moser",
                  Gender = Gender.Male,
                  WebSite = new Uri("http://www.wpftutorial.net"),
                  ReceiveNewsletter = true,
                  Image = "Images/christian.jpg"
              };
              _customers.Add(c);
          }
  
          Customers = CollectionViewSource.GetDefaultView(_customers);
  
          GroupedCustomers = new ListCollectionView(_customers);
  
      }
      public void AddServices()
      {
  
          var _customers = new List&lt;Customer&gt;();
          for (int i = 0; i &lt; 5; i++)
          {
              var c = new Customer
              {
                  FirstName = "Christian",
                  Name = "SrvName",
                  State = "SrvState",
                  LastName = "Moser",
                  Gender = Gender.Male,
                  WebSite = new Uri("http://www.wpftutorial.net"),
                  ReceiveNewsletter = true,
                  Image = "Images/christian.jpg"
              };
              _customers.Add(c);
          }
  
          Customers = CollectionViewSource.GetDefaultView(_customers);
  
          GroupedCustomers = new ListCollectionView(_customers);
  
      }
  }
  </code></pre>
  
  <p>Customer class definition :</p>
  
  <pre><code>public class Customer : INotifyPropertyChanged
      {
          private string _firstName;
          private string _State;
          private string _Name;
          private string _lastName;
          private Gender _gender;
          private Uri _webSite;
          private bool _newsletter;
          private string _image;
      public string FirstName
      {
          get { return _firstName; }
          set 
          {
              _firstName = value;
              NotifyPropertyChanged("FirstName");
          }
      }
      public string State
      {
          get { return _State; }
          set
          {
              _State= value;
              NotifyPropertyChanged("State");
          }
      }
      public string Name
      {
          get { return _Name; }
          set
          {
              _Name = value;
              NotifyPropertyChanged("Name");
          }
      }
  
      public string LastName
      {
          get { return _lastName; }
          set
          {
              _lastName = value;
              NotifyPropertyChanged("LastName");
          }
      }
  
      public Gender Gender
      {
          get { return _gender; }
          set
          {
              _gender = value;
              NotifyPropertyChanged("Gender");
          }
      }
  
      public Uri WebSite
      {
          get { return _webSite; }
          set
          {
              _webSite = value;
              NotifyPropertyChanged("WebSite");
          }
      }
  
      public bool ReceiveNewsletter
      {
          get { return _newsletter; }
          set
          {
              _newsletter = value;
              NotifyPropertyChanged("Newsletter");
          }
      }
  
      public string Image
      {
          get { return _image; }
          set
          {
              _image = value;
              NotifyPropertyChanged("Image");
          }
      }
  
      #region INotifyPropertyChanged Members
  
      public event PropertyChangedEventHandler PropertyChanged;
  
      #endregion
  
      #region Private Helpers
  
      private void NotifyPropertyChanged(string propertyName)
      {
          if (PropertyChanged != null)
          {
              PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
          }
      }
  
      #endregion
  }
  </code></pre>
  
  <p>At the beginning AddServices() method is called.
  After 20 seconds I call another method named AddServicesTimer()
  But it is not updating my Grid View it is updating the list but not view.
  Need help</p>