mirror of
https://github.com/PacktPublishing/Learn-WinUI-3-Second-Edition.git
synced 2026-06-20 12:23:09 +00:00
25 lines
683 B
Plaintext
25 lines
683 B
Plaintext
@page "/tasks"
|
|
<h3>Tasks - (@taskList.Count(task => !task.IsComplete)) incomplete</h3>
|
|
<ul>
|
|
@foreach (var task in taskList)
|
|
{
|
|
<li>
|
|
<input type="checkbox" @bind="task.IsComplete" />
|
|
<input @bind="task.Name" />
|
|
</li>
|
|
}
|
|
</ul>
|
|
<input placeholder="Enter new task..." @bind="newTask" />
|
|
<button @onclick="AddTask">Add task</button>
|
|
@code {
|
|
private IList<TaskItem> taskList = new List<TaskItem>();
|
|
private string? newTask;
|
|
private void AddTask()
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(newTask))
|
|
{
|
|
taskList.Add(new TaskItem { Name = newTask });
|
|
newTask = string.Empty;
|
|
}
|
|
}
|
|
} |