private void Btn_RemoveFavorite_MouseDown(object sender, MouseButtonEventArgs e) { if (LB_Favorite.SelectedIndex != -1) { var route = _favoriteRoutes.FavoriteRoutesList[LB_Favorite.SelectedIndex]; _favoriteRoutes.Remove(route.RouteName); LB_Favorite.Items.Remove(LB_Favorite.Items[LB_Favorite.SelectedIndex]); SerializeFavoriteRoutes(); if (LB_Favorite.Items.Count == 0) { LB_Favorite.Visibility = Visibility.Collapsed; } } }
public static void DeleteFavoriteRoute(string pointOfDeparture, string pointOfDestination) { _favoriteRoutes.Remove(_favoriteRoutes.FavoriteRoutesList.Find(x => x.PointOfDeparture.Equals(pointOfDeparture) && x.PointOfDestination.Equals(pointOfDestination)).RouteName); }