public string this[string propName] { get { if (propName == "AddressTxt") { string reason = ""; if (curAddress == null && !AddressControl.ValidateAddress(curAddressTxt, ref reason)) // we can only select valid items { return(reason); } } return(null); } }
private void btnOk_Click(object sender, RoutedEventArgs e) { ListBoxItem item = (lstAddr.SelectedItem as ListBoxItem); bool bSelected = item != null && item.Tag != null; bool bRemove = cmbEdit.Text.Length == 0; if (!bRemove) { string reason = ""; if (cmbEdit.SelectedItem == null && !AddressControl.ValidateAddress(cmbEdit.Text, ref reason)) { return; } } gridEdit.Visibility = Visibility.Collapsed; //lstAddr.IsEnabled = true; if (bSelected) { if (bRemove) { lstAddr.Items.Remove(item); } else // update item { item.Content = cmbEdit.Text; item.Tag = cmbEdit.Text; } } else if (cmbEdit.Text.Length > 0) { lstAddr.Items.Insert(lstAddr.Items.Count - 1, new ListBoxItem() { Content = cmbEdit.Text, Tag = cmbEdit.Text }); } }