title: DataGrid Exception Handling
body: <p>I have been stuck with this for hours and hope somebody can shed some light on this. Say I have a <code>DataGrid</code> control:</p>
  
  <pre><code>&lt;DataGrid ItemsSource="{Binding Path=RealEstates, ValidatesOnExceptions=True}"
            AutoGenerateColumns="True"
            Name="grdData_RealEstate" 
            Margin="5,5,5,5"
            Style="{StaticResource DataGridStyle}"
            RowStyle="{StaticResource DataGridRowStyle}"&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Which is bound to a propetry that exposes the RealEstates table of a <code>DataSet</code>.</p>
  
  <p>Now when the user deletes a row from this table I would like to perform some checks before allowing or denying the delete. 
  What I have done is to subscribe to the <code>RowDeleting</code> event of the DataTable.</p>
  
  <pre><code>workingDataSet.Tables["realestates"].RowDeleting += Database_RowDeleting;
  </code></pre>
  
  <p>Then in the method that handles it, I just throw an exception. The actual logic will follow once I get this working.</p>
  
  <pre><code>void Database_RowDeleting(object sender, DataRowChangeEventArgs e)
  {
      throw (new Exception("Can't delete"));            
  }
  </code></pre>
  
  <p>This works and raises the exception when I am trying to delete any row from the <code>DataGrid</code>. The problem though is that the <code>DataGrid</code> control is not catching the exception (red border the <code>DataGrid</code> control) which causes my program to shut down and is obviously not what I want. Any idea what I am doing wrong here? How can I get the <code>DataGrid</code> to catch these exceptions? </p>