Hello,
I am working on UI Interactive toolkit to display different parameters. I want to know is there an append method that I can use incase if there are multiple (key,value) pairs for the same parameter. I have created a dictionary which stores multiple key value pairs , now I want to display all of those values using interactive toolkit. How can I do it?
I want to use normal text as sometimes dictionary has only one key,value pair and sometimes its more than one. If thats more than one then i want it to display all key value pairs in different lines as a text.
Hi Aditiben,
To show all values in a dictionary you could use the DropDown component.
- Create the dropdown control and add it to the UI:
var dropdown = new DropDown();
dropdown.Options = new[] { "Option 1", "Option 2", "Option 3" };
dropdown.Selected = "Option 1";
- Retrieve the selected option:
string selectedOption = dropdown.Selected;
In the same way you can also use CheckBoxList and RadioButtonList.
I want to use normal text as sometimes dictionary has only one (key,value) pair and sometimes its more than one. If thats more than one then i want it to display all key value pairs in different lines as a text.
If you want to combine the values in a dictionary and show them as text, you could use the String.Join method as follows:
Dictionary dict;
MyLabel.Text = String.Join(“, “, dict.Select(x => x.Value)); The result is a single string with commas between the values.
Hi Aditiben,
What UI component would you like to use (a label, dropdown, other)?
Do you want to show all values in one UI component, or display a distinct component for every value?