This work :
Index.razor
<SurveyPrompt Title="How is Blazor working for you?" Counter="@Counter" CounterChanged="@CounterChangedFiredEvent" />
<p>Counter: @Counter</p>
@code {
private int Counter = 1;
void CounterChangedFiredEvent(int counter)
{
Counter = counter;
StateHasChanged();
}
}
SuveyPrompt.razor
<input type="button" value="Previuos" @onclick="@Previous" />
<input type="button" value="Next" @onclick="@Next" />
@code {
// Demonstrates how a parent component can supply parameters
[Parameter] string Title { get; set; }
[Parameter]
private int Counter { get; set; }
[Parameter]
Action<int> CounterChanged { get; set; }
void Next()
{
CounterChanged(++Counter);
}
void Previous()
{
CounterChanged(--Counter);
}
}