title: WPF DataGrid extends beyond Grid
body: <p>Been looking at it for 4 hours, guys...  I just can't figure this out (possibly Microsoft bug?)</p>
  
  <p>This is what I have and it's all good except DataGrid control.  As you can see in this video, data goes beyond app's boundary (grid and scroll bar):</p>
  
  <p><a href="https://goo.gl/photos/YnApkZS7v3uZ4TWX6" rel="nofollow">https://goo.gl/photos/YnApkZS7v3uZ4TWX6</a></p>
  
  <p>Since this code is using Material Design library, I stripped it down to basics so that anyone could try it out for themselves.</p>
  
  <pre><code>&lt;Window
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      x:Class="EvolvDirectoryCreeper.MainWindow"
      Height="700" Width="1000"&gt;
  &lt;Grid&gt;
      &lt;Grid.RowDefinitions&gt;
          &lt;RowDefinition Height="Auto"/&gt;
          &lt;RowDefinition Height="30"/&gt;
          &lt;RowDefinition Height="30"/&gt;
          &lt;RowDefinition Height="*"/&gt;
      &lt;/Grid.RowDefinitions&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition/&gt;
          &lt;ColumnDefinition Width="Auto" MinWidth="80"/&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Grid Height="180" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Grid.RowSpan="2"&gt;
          &lt;Grid Margin="10,10,100,10"&gt;
              &lt;Grid.RowDefinitions&gt;
                  &lt;RowDefinition/&gt;
                  &lt;RowDefinition/&gt;
                  &lt;RowDefinition/&gt;
              &lt;/Grid.RowDefinitions&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition/&gt;
                  &lt;ColumnDefinition/&gt;
              &lt;/Grid.ColumnDefinitions&gt;
              &lt;TextBox Grid.Column="0" Grid.Row="0" Margin="4"/&gt;
              &lt;TextBox Grid.Column="0" Grid.Row="1" Margin="4"/&gt;
              &lt;TextBox Grid.Column="0" Grid.Row="2" Margin="4"/&gt;
              &lt;Button Grid.Column="1" Grid.Row="0" Margin="4"/&gt;
              &lt;Button Grid.Column="1" Grid.Row="1" Margin="4"/&gt;
              &lt;Button Grid.Column="1" Grid.Row="2" Margin="4"/&gt;
          &lt;/Grid&gt;
      &lt;/Grid&gt;
      &lt;Grid Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" Margin="10"&gt;
          &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="400"/&gt;
              &lt;ColumnDefinition Width="*"/&gt;
          &lt;/Grid.ColumnDefinitions&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="Auto"/&gt;
              &lt;RowDefinition Height="Auto"/&gt;
              &lt;RowDefinition Height="*"/&gt;
          &lt;/Grid.RowDefinitions&gt;
          &lt;Label Height="40" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Margin="4" Padding="0,15,0,0" HorizontalAlignment="Left" VerticalAlignment="Bottom"/&gt;
          &lt;ProgressBar Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Margin="4" VerticalAlignment="Bottom"/&gt;
          &lt;Label Content="Good" Grid.Column="0" Grid.Row="1" Margin="4,30,0,0"/&gt;
          &lt;Label Content="Bad" Grid.Column="2" Grid.Row="1" Margin="4,30,0,0"/&gt;
          &lt;DataGrid Grid.Column="0" Grid.Row="2"/&gt;
          &lt;DataGrid Grid.Column="2" Grid.Row="2" ItemsSource="{Binding Path=BadFoldersHistory}"/&gt;
      &lt;/Grid&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>
  
  <p>And this is C#:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Collections.ObjectModel;
  using System.ComponentModel;
  using System.Diagnostics;
  using System.Globalization;
  using System.IO;
  using System.Linq;
  using System.Reflection;
  using System.Text.RegularExpressions;
  using System.Threading;
  using System.Threading.Tasks;
  using System.Windows;
  using System.Windows.Controls;
  using System.Windows.Input;
  using System.Windows.Media;
  using System.Windows.Threading;
  
  namespace EvolvDirectoryCreeper
  {
      public partial class MainWindow : Window, INotifyPropertyChanged
      {
          private ObservableCollection&lt;string&gt; m_badFoldersHistory = new ObservableCollection&lt;string&gt;();
          public ObservableCollection&lt;string&gt; BadFoldersHistory
          {
              get { return m_badFoldersHistory; }
              set { 
                  m_badFoldersHistory = value;                                                                           
                  OnPropertyChanged("BadFoldersHistory");
              }
          }
  
          public virtual event PropertyChangedEventHandler PropertyChanged;
          public virtual void OnPropertyChanged(string name)
          {
              PropertyChangedEventHandler handler = PropertyChanged;
              if (handler != null)
              {
                  handler(this, new PropertyChangedEventArgs(name));
              }
          }
  
          private Dispatcher MainWindowDispatcher;
  
          public MainWindow()
          {
              InitializeComponent();
  
              DataContext = this;
              MainWindowDispatcher = Dispatcher;
  
              for (int i = 0; i &lt; 40; i++)
                  BadFoldersHistory.Add("d");
          }
      }
  }
  </code></pre>
  
  <p>I already tried "Auto" instead of "*" in the last row of each Grid but doesn't help.  I need to keep this Grid structure to maintain Material Design FAB location and proper resizing.
  ANY help would be greatly appreciated!</p>