Last active
April 9, 2018 21:38
-
-
Save gskachkov/def2e3acdf719163731bc21720e62d00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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