0
votes

i have one for loop that create 3 RadioButton with IsChecked Property true.

I'm adding the RadioButton to StackPanel in ui.When it completed adding radiobuttons i see only the last radiobutton added in page have IsChecked Property to true everyone else has false.

so when layout updates with new radiobutton added all others radiobutton in the stackpanel are set to false here is the code

for(var l = 0 ; l< 3 ; l++){
   RadioButton radiobutton = new RadioButton();
   radiobutton.IsChecked = true;
   stackpanel.children.add(radiobutton);
}
1
I need to see your full code (for the list, at least). How are you adding the list? Is there a page_load() in between?A. Abramov
Well, that is the very nature of radiobuttons: only one in a group of them is checked.TaW
sorry i wasn't very clear , i have two stackpanel so in every stackpanel i added three RadioButtons button only the last radioButton of last stackpanel is checkedGranit Berisha
@GranitBerisha Can you show an example of this behaviour in action?Mike Eason

1 Answers

2
votes

As TaW already commented, with radiobuttons only one can be checked. If you want multiple checks I suggest you use checkboxes.