adospace / reactorui-maui

MauiReactor is a MVU UI framework built on top of .NET MAUI
MIT License
586 stars 49 forks source link

RadioButton question #69

Closed alex-relov closed 1 year ago

alex-relov commented 1 year ago

How to use RadioButton component in reactorui-maui?

adospace commented 1 year ago

Here is an example:

class MainPageState
{
    public bool Checked1 { get; set; }
    public bool Checked2 { get; set; }
}

class MainPage : Component<MainPageState>
{
    public override VisualNode Render() 
        => new ContentPage
        {
            new VStack
            {
                new RadioButton()
                    .IsChecked(State.Checked1)
                    .OnCheckedChanged((sender, args) => SetState(s => s.Checked1 = args.Value))
                    ,

                new RadioButton()
                    .IsChecked(State.Checked2)
                    .OnCheckedChanged((sender, args) => SetState(s => s.Checked2 = args.Value))
            }
            .HCenter()
            .VCenter(),
        };
}