Xamarin.Forms.InputKit
Xamarin.Forms.InputKit copied to clipboard
RadioButtonGroupView SelectedItemChanged on iOS don't work
Hi everyone.
I have a issue on iOS using RadioButton and RadioButtonGroupView. On my application I need to create dynamic quality polls with questions and options between 1 and 5 as an answers, the questions have category group, so I made this polls from codebehind, on android the radio can be selected without problems, but on iOS don't work.
Here are the code and data that I'm using, the event RadioGroupView_SelectedItemChanged
on iOS isn't been triggered when tap the option.
[{
"Id":"cb04328f-37c9-4d2a-9dd4-6ecb66a1934c",
"Category":"Demo Category ",
"EncuestaId":"44572e9f-db44-4350-afc5-fa71bee839c8",
"Question":[
{
"Id":"1b656cf1-826f-4714-b4e7-5677ff577176",
"Text":"Question no 1",
"Options":[
{ "Option":"1" },
{ "Option":"2" },
{ "Option":"3" },
{ "Option":"4" },
{ "Option":"5" }
]
},
{
"Id":"61698bd5-b6bc-47d1-b645-1a547f093beb",
"Text":"Question no 2",
"Options":[
{ "Option":"1" },
{ "Option":"2" },
{ "Option":"3" },
{ "Option":"4" },
{ "Option":"5" }
]
},
{
"Id":"fb6752d6-d682-4bbf-a021-943fdddeb973",
"Text":"Question no 3",
"Options":[
{ "Option":"1" },
{ "Option":"2" },
{ "Option":"3" },
{ "Option":"4" },
{ "Option":"5" }
]
}
]
}]
// pollContainer is a StackLayout element on XAML.
foreach (var category in data.poll)
{
var sectionContainer = new StackLayout { Padding = new Thickness(15, 10)};
foreach (var question in category.Question)
{
var optionGrid = new Grid();
question.Options.ForEach(p =>
{
var option = new AnswerData { AnswerValue = int.Parse(p.Option), QuestionId = question.Id };
optionGrid.Children.AddHorizontal(new RadioButton { Text = p.Option, Value = option});
});
sectionContainer.Children.Add(
new Label { Text = question.Text, Padding = 0, Margin = 0 });
var optionContainer = new RadioButtonGroupView
{
SelectedIndex = 0,
Padding = new Thickness(0, 8)
};
optionContainer.SelectedItemChanged += RadioGroupView_SelectedItemChanged;
optionContainer.Children.Add(optionGrid);
sectionContainer.Children.Add(optionContainer);
}
// Inserta category con sus preguntas
pollContainer.Children.Add(
new Label { Text = category.Category, FontSize = 22, FontAttributes = FontAttributes.Bold });
// Agrega las preguntas al poll
pollContainer.Children.Add(sectionContainer);
}
private void RadioGroupView_SelectedItemChanged(object sender, EventArgs e)
{
// This event don't work on iOS
}
Any help is useful I checked if any element is been above of the options.
This is an image with the result, the background color is to see if there is an element above the options.