1

I want to create a radio button list in zebble.net to force the user to select 1 option among 3 choices of opt1 to opt3 enter image description here

I have checked the documentation and found only the checkbox and optionsList controls.

So I deduct that something like below code can render a radioButtonList

  <OptionsList Id="MyOptionsList" Direction="Horizontal" MultiSelect="false">    
    <CheckBox Id="MyCheckBox1" Checked="false"> </CheckBox>
    <CheckBox Id="MyCheckBox2" Checked="false"> </CheckBox>
    <CheckBox Id="MyCheckBox3" Checked="false"> </CheckBox>
    </OptionsList>

but it will render nothing.what is the problem and how this OptionsList works i could not find any sample showing working usages of this control.

I appreciate can show how this can be done in zebble or in pure xamarin Forms.

Iman
  • 17,932
  • 6
  • 80
  • 90

1 Answers1

1

Based on the documentation, you should use the DataSource property of the OptionsList.

So remove the nested CheckBox elements, and instead set the DataSource property:

<OptionsList Id="MyOptionsList" Direction="Horizontal"
     MultiSelect="false" DataSource="GetMyOptions()" />   

Then in your code behind file, add the method to return the data:

IEnumerable<string> GetMyOptions()
{
    return new [] { "My Option1", "My Option2", "My Option3" };
}
Paymon
  • 1,173
  • 1
  • 9
  • 26
  • thanks,in the documentation it is written "You can bind" and you are saying "you should use" the DataSource and that was a little misleading for me and thought it is optional and I also can insert the items in the markup because there were no compile errors, but it seems that it is in fact a must – Iman Apr 10 '17 at 07:29