Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Create a Radio Switch group with multiple buttons

henda79henda79 Member ✭✭
edited October 10 in Xamarin.Forms

The idea here is simple, I've got 2 or more buttons and want to have them act like Radio Buttons. So only one can be Checked at any time, and when when is checked the others must uncheck themselves. I'm using MVVM so don't want to go down the route of code behind although it would have been easier for this.

Here is the XAML I've tried which locks up.

            <Label Text="Group Header Sorting" TextColor="{DynamicResource InverseTextColor}"/>
            <StackLayout Orientation="Horizontal" Spacing="0">
                <buttons:SfButton x:Name="GroupHeaderSortAscButton" Text="Ascending" HeightRequest="35" WidthRequest="90" IsChecked="{Binding Source={x:Reference GroupHeaderSortDescButton}, Path=IsChecked, Converter={converters:InverseBoolConverter}}">

                <buttons:SfButton x:Name="GroupHeaderSortDescButton" Text="Descending" HeightRequest="35" WidthRequest="90" IsChecked="{Binding Source={x:Reference GroupHeaderSortAscButton}, Path=IsChecked, Converter={converters:InverseBoolConverter}}">

As soon as one of the buttons is pressed the app locks up. I'm fairly sure this can be achieved using the PageModel but that means my UI logic is not where I want it and there will be a ton of extra properties for each of the bindings on the buttons.

I'm aware that from XF 4.6 they introduced the RadioButton control, I've tried this and its buggy and according to comments on Git Hub it will have major changes in XF 5, so I don't want to implement this experimental version.

Best Answer


  • henda79henda79 Member ✭✭

    So I see why this locks up, so what I need is a solution to do this in the XAML.

  • henda79henda79 Member ✭✭

    ColeX, so simple but works.

    I was looking into Behaviors and Triggers but the XAML was getting quite complex, so I gave up and used SyncFusion's Segmented Control.

    Anyway, thanks for the input

Sign In or Register to comment.