//Close : closes this window
 private void gridfindclosebutton_Click(object sender, RoutedEventArgs e)
 {
     dp.SwitchSelectionMode("row"); //single row selection mode is set for the datagrid. It was default.
     dp.MatchIndex = 0;             //resetting back to zero so that next time it should not start with the last value
     this.Close();
 }