void s_LostFocus(object sender, RoutedEventArgs e) { string new_host = (sender as TextBox).Text; if (new_host == org_host) { return; } HostViewModel vm = this.DataContext as HostViewModel; // delete org host vm.Del(org_host); // add new host vm.Add(new_host); }