private void ApplicationBarIconButton_Click(object sender, EventArgs e) { switch ((sender as ApplicationBarIconButton).Text) { case "add": PopupAddLocation.IsOpen = true; break; case "remove": MessageBoxResult r = MessageBox.Show(String.Format(CultureInfo.InvariantCulture, "Are you sure you want to remove {0} from your list of locations?", (WeatherList.Items[WeatherList.SelectedIndex] as Weather).Location), String.Empty, MessageBoxButton.OKCancel); if (r == MessageBoxResult.OK) { client.RemoveWeatherLocationAsync(Settings.CachedAuthenticationToken, (WeatherList.Items[WeatherList.SelectedIndex] as Weather).Location); } break; case "gps": ShowProgress(); watcher.Start(); break; } }