private void ChangeAddress_TextChanged(object sender, TextChangedEventArgs e) { if (ChangeAddress.Text.Equals("")) { boxic2.Visibility = Visibility.Collapsed; Adrese.Visibility = Visibility.Collapsed; } City city = null; List <string> gradovi = new List <string>(); Adrese.ItemsSource = new List <string>(); if (!ChangeCurrentCity.Text.Equals("")) { try { string[] parts = ChangeCurrentCity.Text.Split(", "); string citystr = parts[0]; City ci = new City() { Name = citystr }; city = cityController.GetCityByName(ci); } catch (Exception) { } } if (city != null) { foreach (Address address in addressController.GetAdressesByCity(city)) { if (address.Street.ToLower().Contains(ChangeAddress.Text)) { gradovi.Add(address.Street + ", " + address.Number.ToString()); } } } else { foreach (Address address in addressController.GetAll()) { if (address.Street.ToLower().Contains(ChangeAddress.Text)) { gradovi.Add(address.Street + ", " + address.Number); } } } if (gradovi.Count > 0) { boxic2.Visibility = Visibility.Visible; Adrese.Visibility = Visibility.Visible; } Adrese.ItemsSource = gradovi; }