title: Adding data to datagrid in User Control
body: <p>I made two windows one with user control and i stuck with datagrid.
  I want to add data in MainWindow and show it in UserControl(Window2) but it's not working, when i change usercontrol to simple window it's fine and works. How can I rewrite It? Im newbie and just learning c# and wpf :)</p>
  
  <p>MainWindow.xaml</p>
  
  <pre><code>public partial class MainWindow : Window
  {
      GridControl ngridControl = new GridControl();
      GridWindow ngridWindow = new GridWindow();
  
      public MainWindow()
      {
          InitializeComponent();
          ngridWindow.Show();
      }
  
      private void Button_Click(object sender, RoutedEventArgs e)
      {
          Information item = new Information();
          item.id = name_box.ToString();
          item.name = number_box.ToString();
          ngridControl.informationList.Add(item);
      }
  }
  </code></pre>
  
  <p>GridControl.xaml</p>
  
  <pre><code>public partial class GridControl : UserControl
  {
      public ObservableCollection&lt;Information&gt; informationList = new ObservableCollection&lt;Information&gt;();
  
      public GridControl()
      {
          InitializeComponent();
          dataGrid.ItemsSource = informationList;
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Information.class</p>
  
  <pre><code>public class Information
  {
      public string name { get; set; }
      public string id { get; set; }
  }
  </code></pre>
  
  <p>GridWindow.xaml</p>
  
  <pre><code>&lt;Window x:Class="WpfApp5.GridWindow"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:local="clr-namespace:WpfApp5"
      mc:Ignorable="d"
      Title="GridWindow" Height="450" Width="800"&gt;
  &lt;Grid&gt;
      &lt;local:GridControl&gt; &lt;/local:GridControl&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>