-
Notifications
You must be signed in to change notification settings - Fork 6
Binding Events
Nathan Smith edited this page Nov 15, 2025
·
1 revision
These conventions keep Fluent UI + Syncfusion components in sync with EF models inside the .NET 9 Blazor host. Follow them to avoid double updates, event floods, or validation regressions.
-
Bind + callback – always pair an
@bind-*directive with a method (@bind-Value:after,OnChange, etc.) when the UI writes to the database. -
Async first – callbacks that touch services or EF must return
Taskand be awaited. Avoidasync void. -
PascalCase attributes – Fluent/Syncfusion components use PascalCase (
OnChange). DOM events stay lowercase (@oninput). -
Small lambdas – keep inline lambdas to one statement (e.g.,
@(args => SaveProposal(true))). Move logic into a method when it grows. -
Immediate="true"– prefer built-in Immediate bindings instead of manual@oninputwhen you need per-keystroke updates.
| Control | Binding | Change hook | Example |
|---|---|---|---|
FluentTextField |
@bind-Value |
@bind-Value:after="ApplyFilters" or Immediate="true"
|
Domain/Attachments/Components/AttachmentListGrid.razor |
FluentCheckbox |
@bind-Value |
OnChange="OnCheckedChanged" |
Domain/Proposals/Components/ProposalDetails.razor |
FluentRadioGroup |
@bind-Value |
OnChange="BillTypeChanged" |
Domain/Proposals/Components/ProposalDetails.razor |
SfDropDownList |
@bind-Value |
@bind-Value:after="OnSelectionChange" + <DropDownListEvents ValueChange="OnSelectionChange" />
|
Domain/Accounting/Components/SettlementScreen.razor |
SfNumericTextBox |
@bind-Value |
OnChange="@(args => SaveProposal(true))" |
Domain/Proposals/Components/ProposalDetails.razor |
SfDatePicker |
@bind-Value |
OnChange="@(args => OnDateChanged())" (lambda required) |
Domain/Renewals/Components/Submissions.razor |
SfCheckBox |
@bind-Checked |
@onchange="SaveProposalSimple" (explicit closing tag) |
Domain/Proposals/Components/ProposalDetails.razor |
-
TextField/TextArea – use
Immediate="true"for filters; for expensive operations use@bind-Value:afterto debounce inside your method. -
NumberField –
ValueChanged+ValueExpressionare required when used insideEditForm. Example:Domain/Accounting/Components/SettlementScreen.razor. -
Checkbox –
@bind-Valueworks for boolean states; avoid@bind-Checkedwith Fluent components. -
Combobox – prefer Fluent Combobox for short lists, Syncfusion for large datasets. When using Combobox, handle
ValueChangedandTValueexplicitly.
@using Syncfusion.Blazor
@using Syncfusion.Blazor.DropDowns
@using Syncfusion.Blazor.Inputs<SfDropDownList TItem="RelationshipTypeItem" TValue="RelationshipType"
DataSource="@RelationshipTypes"
@bind-Value="SelectedRelationship"
@bind-Value:after="OnRelationshipChanged">
<DropDownListFieldSettings Text="DisplayName" Value="Value" />
<DropDownListEvents TValue="RelationshipType" TItem="RelationshipTypeItem"
ValueChange="OnRelationshipChanged" />
</SfDropDownList>- Generics (
TItem,TValue) must matchDataSourceand bound property. - Use
<DropDownListEvents>forValueChange; do not putValueChangeon the root element. - Filtering? Set
AllowFiltering="true"and supply aFilterhandler orFilterType, but not both.
<SfDatePicker TValue="DateTime?"
@bind-Value="Proposal.SendDate"
OnChange="@(args => OnSendDateChanged())" />- Use lambda to ignore event args; direct method references fail because Syncfusion expects a parameter.
<SfNumericTextBox TValue="decimal?"
@bind-Value="Proposal.BrokerFee"
Format="C2"
OnChange="@(args => SaveProposal(true))" />- Avoid
ValueChange(wrong event) – useOnChangeor@bind-Value:after.
- Use
<EditForm>+<DataAnnotationsValidator>where possible;ValueExpression="() => Model.Property"is required for Syncfusion + validation. -
ValidationMessagepairs nicely with Fluent/Syncfusion controls inside forms.
- Mixing DOM events (
@onchange) with component events on the same control - Self-closing
<SfCheckBox />tags (Syncfusion needs explicit closing tags) -
async voidcallbacks – alwaysasync Task - Passing
nullDataSourcetoSfDropDownList– pre-initialize withArray.Empty<T>() - Using
@bind-Valueand manualValue/ValueChangedsimultaneously
- See
Domain/Proposals/Components/ProposalDetails.razorfor nearly every control pattern in one file -
Domain/Attachments/Components/AttachmentListGrid.razorshows Fluent filters +Immediate -
Domain/Accounting/Components/SettlementScreen.razordemonstrates numeric/date/dropdown combos with data annotations
Use this doc as the authoritative source before nudging Cursor/Copilot—copy/paste the snippets above so generated code compiles the first time.
Quickfire Wiki • Generated from Qf-Docs/wiki • Last updated: 2025-11-14.
See the main repo for README + issues.
- Home
- Getting Started
- System Architecture
- Release Notes
- Features
- Agents & AI
- Reference
- Guides
- Integrations
- Archive