How does two-way data binding work in Blazor, and what is the underlying Value / ValueChanged pattern behind @bind?
Last updated
@bindis compiler sugar: it expands to avalueassignment plus anonchangehandler that writes the input back to the field.For your own components, a parameter
Xplus anEventCallbacknamedXChangedenables@bind-X(e.g.Value/ValueChanged).Updates fire on
onchange(blur) by default. Use@bind:event="oninput"to update on every keystroke.
- https://learn.microsoft.com/en-us/aspnet/core/blazor/components/data-binding?view=aspnetcore-10.0
- https://www.scribd.com/document/665747494/ASP-net-Core-Blazor-Data-Binding-Microsoft-Learn
- https://www.meziantou.net/two-way-binding-in-blazor.htm
- https://www.ssw.com.au/rules/blazor-use-bind-value-after-instead-of-valuechanged
- https://www.telerik.com/blazor-ui/documentation/knowledge-base/value-changed-validation-model