Skip to content

Instantly share code, notes, and snippets.

@gskachkov
Last active April 9, 2018 21:38
Show Gist options
  • Save gskachkov/def2e3acdf719163731bc21720e62d00 to your computer and use it in GitHub Desktop.
Save gskachkov/def2e3acdf719163731bc21720e62d00 to your computer and use it in GitHub Desktop.
[Layout(typeof(MainLayout)), Route("/counter")]
public class Counter : BlazorComponent
{
private int currentCount = 0;
protected override void BuildRenderTree(...)
{
...
builder.AddContent(4, "Current count: ");
builder.AddContent(5, (int) this.currentCount);
...
builder.OpenElement(7, "button");
builder.AddAttribute(8, base.onclick(
new Action(this, this.IncrementCount)
));
builder.AddContent(9, "Click me");
...
}
private void IncrementCount()
{
this.currentCount++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment