Prompt choices dynamically #167
-
Is there some way to add choices dynamically ? |
Beta Was this translation helpful? Give feedback.
Answered by
patriksvensson
Dec 14, 2020
Replies: 1 comment 1 reply
-
@joserocha Not sure I understand what you mean, but does something like this solve it for you? // Build the fruit list
var fruits = new List<string>();
fruits.Add("banana");
fruits.Add("orange");
// Build the prompt
var prompt = new TextPrompt<string>("What's your [green]favorite fruit[/]?");
foreach(var fruit in fruits) {
prompt.AddChoice(fruit);
}
// Show the prompt
var selectedFruit = AnsiConsole.Prompt(prompt); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
patriksvensson
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@joserocha Not sure I understand what you mean, but does something like this solve it for you?