Я пытаюсь изменить имя элемента ListBox и его содержимое ярлыка, как только ингредиенты этого элемента ListBox совпадают с другим списком.Вот мое решение, но оно не работает.
public void changeSciName()
{
foreach (var recipe in RecipeList)
{
bool equalIngredients = recipe.Recipe.All(selectedPotion.MyIngredients.Contains) && recipe.Recipe.Count == selectedPotion.MyIngredients.Count;
if (equalIngredients)
{
selectedPotion.Name = recipe.RecipeName;
scientificNameLabel.Content = recipe.RecipeName;
RefreshPotionListBox();
}
}
}
void RefreshPotionListBox()
{
potionListBox .Items.Clear();
foreach (var item in potionNames)
{
potionListBox.Items.Add(item);
}
}