Skip to content

Add @bind-Value to all Parameters #487

Description

@TimPurdum

Using the Code Generator, add the {ParameterName}Changed Parameter to all current non-EventCallback parameters. This exposes 2-way binding to end users, who can then use @bind-ParameterName="_localVariable" to bind.

Example:

public class DistanceMeasurement2DWidget: Widget
{

...

    // existing parameter
    [Parameter]
    [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
    public DistanceMeasurement2DViewModel? ViewModel { get; set; }

    // new parameter
    [Parameter]
    [JsonIgnore]
    public EventCallback<DistanceMeasurement2DViewModel> ViewModelChanged { get; set; }
}

Usage:

<MapView>
  <Map>
  </Map>
  <DistanceMeasurement2DWidget @ref="_distanceWidget" 
                                     Visible="false" 
                                     Position="OverlayPosition.BottomRight"
                                     @bind-ViewModel="_distanceWidgetViewModel"
                                     @bind-ViewModel:after="StateHasChanged" />
</MapView>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions