Skip to content

Two-Way binding #2

@KeterM

Description

@KeterM

Hi Mariano, thank you for your project. It it was just what I was looking for.
I confirm that it works in Blazor Web Assembly too (not only Server version).
I suggest a little change in code to get Two-Way Binding:

[Parameter]
public string ColorStr { get; set; }

[Parameter]
public EventCallback<string> ColorStrChanged { get; set; }

async Task UpdateIt(ChangeEventArgs e)
{
   ColorStr = e.Value.ToString();       
   await ColorStrChanged.InvokeAsync(ColorStr); 
}

So in the page you can use it in this way

<ColorSelector @bind-ColorStr="@MyColor"></ColorSelector>

Best regards,
Mattia

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions