动态标签内容和列表框项目名称更改

时间:2018-12-08 21:13:48

标签: c# listbox label

我试图在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);
        }
    }

0 个答案:

没有答案