private void btnSearch_Click(object sender, RoutedEventArgs e) { listCodes.BeginInit(); listCodes.ItemsSource = null; listCodes.Items.Clear(); //if (mDataAccess.getPostalCodes(txtCity.Text.Trim().ToUpper(), txtSuburb.Text.Trim().ToUpper(), txtCode.Text.Trim().ToUpper(), mIsPhysical, pCodes)) try { var postalCodes = mVerifyService.GetPostalCode(txtCity.Text.Trim().ToUpper(), txtSuburb.Text.Trim().ToUpper(), txtCode.Text.Trim().ToUpper(), mIsPhysical); pCodes = postalCodes; listCodes.ItemsSource = postalCodes; } catch (Exception ex) { MessageBox.Show(this, "Could not get postal codes \n\n" + ex.Message, "Postal Codes", MessageBoxButton.OK, MessageBoxImage.Information); listCodes.EndInit(); } }