title: how can i make my xmldataprovider update my datagrid's content on filechange?
body: <p>I've been following this <a href="https://youtu.be/Yt0_5nHymO0" rel="nofollow noreferrer">tutorial</a> and bound my Datagrid successfully to an XML data provider resource.</p>
  
  <p>My grid didn't update when the xmlfile (that the xmldataprovider was referenced to) changed.</p>
  
  <p>So I followed this guy's <a href="http://www.infosysblogs.com/microsoft/2008/03/wpf_updating_xmldataprovider_w.html" rel="nofollow noreferrer">tutorial</a> and while I could get a notice every time the file changed (the tutorial offers a custom class 'myxmldataprovider' that extends xmldataprovider and has a filesystem watcher listening for file change. There is a function in the class called "on file changed" and it is accessed when the XML file is changed). Using refresh in the file changed function, as suggested by 2nd tutorial didn't do anything to update the datagrid or the dataprovider's content.</p>
  
  <p>I'm really late on my project.. and this seems to be the sole thing keeping me from moving on. I've searched the internet and browsed countless forums. and have yet to find a clear answer that works.</p>
  
  <p>custom class</p>
  
  <pre><code>public class MyXmlDataProvider: XmlDataProvider
  {
  
      public new Uri Source
      {
          get { return base.Source; }
          set
          {
  base.Source = value;
              FileSystemWatcher watcher = new FileSystemWatcher();
              //set the path of the XML file appropriately as per your requirements
              watcher.Path = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\"));
              //name of the file i am watching
              watcher.Filter = value.OriginalString;
  
              //watch for file changed events so that we can refresh the data provider
              watcher.Changed += new FileSystemEventHandler(file_Changed);
  
  
              //finally, don't forget to enable watching, else the events won't fire           
              watcher.EnableRaisingEvents = true;
          }
      }
  
      void file_Changed(object sender, FileSystemEventArgs e)
      {base.refresh();
  
  }
  </code></pre>
  
  <p>xaml</p>
  
  <pre><code>&lt;local:MyXmlDataProvider Source="XMLFile123.xml"
                       XPath="firstnode" x:Key="xml" /&gt;
  &lt;/Window.Resources&gt;
  &lt;DataGrid Name="CustomerGrid" AutoGenerateColumns="False"
                ItemsSource="{Binding Source={StaticResource xml},XPath=*}"&gt;
          &lt;DataGrid.Columns&gt;
              &lt;DataGridTextColumn Binding="{Binding XPath=@attribute1}"
                                  Header="attribute1" /&gt;
              &lt;DataGridTextColumn Binding="{Binding XPath=@attribute2}"
                                  Header="attribute2" /&gt;
              &lt;DataGridTextColumn Binding="{Binding XPath=@attribute3}"
                                  Header="attribute3" /&gt;
              &lt;DataGridTextColumn Binding="{Binding XPath=@attribute4"
                                  Header="attribute4" /&gt;
          &lt;/DataGrid.Columns&gt;
      &lt;/DataGrid&gt;
  </code></pre>