I am using InputKit plugin to use radio buttons.
<StackLayout VerticalOptions="Center" HorizontalOptions="Center"> <input:RadioButtonGroupView x:Name="gender" SelectedItemChanged="genderSelected"> <input:RadioButton Text="Male" /> <input:RadioButton Text="Female" /> </input:RadioButtonGroupView> </StackLayout>
I want to read the values from radio buttons.I am trying to use the x:Name attribute but I get errors for the same behind the .cs file.
namespace Testing { [XamlCompilation(XamlCompilationOptions.Compile)] public partial class Greet : ContentPage { public Greet() { InitializeComponent(); } public void genderSelected(object sender, EventArgs e) { var value = gender.Items <------here gender is not defined which I want to access from x:Name attribute }
Answers
Check source code of RadioButtonGroupView , there is no available property called
Items
.Get the values by retrieving the
RadioButtonGroupView.Children
.