Dev
Dev

Reputation: 329

RadioButton Command property not working with xamarin.forms

RadioButton command property not working after updated from Xamarin.Forms 4.7 to Xamarin.Forms 5.0.0.2337. what are the alternative ways to use command in ViewModel not with codebehind.

Upvotes: -1

Views: 1188

Answers (1)

Jessie Zhang -MSFT
Jessie Zhang -MSFT

Reputation: 13899

Yes,since Xamarin.Forms 5.0.0, the property Command has been removed from RadioButton.

If you want to run a command upon state change then you can use the event CheckedChanged.

    <RadioButton Content="test">
        <RadioButton.Behaviors>
            <local:EventToCommandBehavior EventName="CheckedChanged" Command="{Binding Source={x:Reference Page}, Path=BindingContext.RadioCommand}"   CommandParameter="V"/>
        </RadioButton.Behaviors>
    </RadioButton>

For EventToCommandBehavior.cs, you can refer sample code here: https://github.com/xamarin/xamarin-forms-samples/tree/main/Behaviors/EventToCommandBehavior/EventToCommandBehavior/Behaviors .

Note:

Page is the x:Name of current page.

Upvotes: 3

Related Questions