private void btnShow_Click(object sender, RoutedEventArgs e) { try { string CityName = txtRegion.Text; List <Property> viewProperty = propertyBL.GetAllPropertyByRegionBL(CityName); if (viewProperty != null && viewProperty.Count > 0) { dgViewProperties.DataContext = viewProperty; } else { MessageBox.Show("No record found"); } } catch (EasyHousingSolutionException ex) { MessageBox.Show("Error: " + ex); } catch (Exception ex) { MessageBox.Show("Error: " + ex); } }