title: Prevent multiple row selection in WPF DataGrid
body: <p>I have the following XAML markup in a WPF DataGrid:</p>
  
  <pre><code>&lt;DataGrid ItemsSource="{Binding ResultList}" Grid.ColumnSpan="4" Grid.Row="7" Height="150" 
            HorizontalAlignment="Left" Margin="10,0,0,0" Name="gvResults" 
            VerticalAlignment="Bottom" Width="590" AutoGenerateColumns="False" SelectionChanged="gvResults_SelectionChanged"
             SelectionUnit="FullRow"&gt;
      &lt;DataGrid.Columns&gt;
          &lt;DataGridTextColumn IsReadOnly="True" Binding="{Binding Name}" Header="Name" ScrollViewer.VerticalScrollBarVisibility="Auto" Width="190" /&gt;
          &lt;DataGridTextColumn IsReadOnly="True" Binding="{Binding Surname}" Header="Surname" Width="190" /&gt;
          &lt;DataGridTextColumn IsReadOnly="True" Binding="{Binding Age}" Header="Age" Width="*" /&gt;
      &lt;/DataGrid.Columns&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Is it possible to prevent users from selecting multiple rows while holding down the <kbd>Ctrl</kbd> key or selecting multiple rows with a mouse?</p>
  
  <p>I've tried the following code in the SelectionChanged event but it does not work:</p>
  
  <pre><code>private void gvResults_SelectionChanged(object sender, SelectionChangedEventArgs e)
  {
      if (gvResults.SelectedItems.Count &gt; 1)
      {
          e.Handled = true;
      }
  }
  </code></pre>