title: Binding to XMLDataProvider
body: <p>Made a simple test project where i try to bind to a xmldatasource in a proto viewmodel</p>
  
  <pre><code>public partial class Window1 : Window
  {
      //private XmlDataProvider _provider = new XmlDataProvider(); 
      private MyViewModel _myViewModel = new MyViewModel();
      public Window1()
      {
          InitializeComponent();
          this.DataContext = _myViewModel ;
      }    
  }
  
  public class MyViewModel
  {    
      public MyViewModel()
      {
          LoadXMLData();
      }
  
      private XmlDataProvider _provider = new XmlDataProvider(); 
      public XmlDataProvider Reports
      {
          get { return _provider; }
          set { _provider = value; }
      }    
  
      private void LoadXMLData()
      {
          string filePath = Directory.GetCurrentDirectory() + @"\Reports2.xml";
  
          System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
          doc.Load(filePath);
          _provider.Document = doc;
          _provider.XPath = @"Reports/Report";
      }
  }
  </code></pre>
  
  <p>If i try to bind a listbox like this. I get nothing</p>
  
  <pre><code>&lt;ListBox x:Name="TeamsListBox" Margin="0,0,0,20" DockPanel.Dock="Left"
      ItemsSource="{Binding Reports}"
      ItemTemplate="{StaticResource teamItemTemplate}"
      IsSynchronizedWithCurrentItem="True"
      Visibility="Visible" SelectionMode="Single"&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>If i instead change datacontext to </p>
  
  <pre><code>this.DataContext = _myViewModel.Reports
  </code></pre>
  
  <p>And listbox to</p>
  
  <pre><code>&lt;ListBox x:Name="TeamsListBox" Margin="0,0,0,20" DockPanel.Dock="Left"
      ItemsSource="{Binding}"
      ItemTemplate="{StaticResource teamItemTemplate}"
      IsSynchronizedWithCurrentItem="True"
      Visibility="Visible" SelectionMode="Single"&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>Then it works, how do i bind to the viewmodel so i can fill it with more than just on xmldatasource</p>
  
  <p>If i put a breakpoint on property Report i can see that it is called when i do {Binding Reports} but the list is still empty.</p>
  
  <p>UPDATE</p>
  
  <p>I can do this binding in code and then it works</p>
  
  <pre><code> Binding binding = new Binding();
              binding.Source = _myViewModel.Reports;
              binding.XPath = @"Reports/Report";
              TeamsListBox.SetBinding(ListBox.ItemsSourceProperty, binding);
  </code></pre>
  
  <p>Why cant i do that in XAML</p>