private Recipe ExtractRecipe(object listbox) { if ((listbox as ListBox).SelectedItem == null) { return(null); } string recipeName = (listbox as ListBox).SelectedItem.ToString(); return(RecipeManager.FindByName(recipeName)); }