void dataGrid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
IInputElement element = e.MouseDevice.DirectlyOver;
if (element != null && element is FrameworkElement)
{
// If the element selected is of type scroll viewer, it means that the
// user is not clicking on a data grid result. In that case, remove
// the current selection
if (element.GetType() == typeof(System.Windows.Controls.ScrollViewer))
{ ResultGrid.SelectedIndex = -1; }
}
}