
A full-featured Todo application demonstrates the core patterns used in real Blazor WASM projects.
TodoList, TodoItem, AddTodoForm, FilterBarpublic class TodoState
{
public List<TodoItem> Items { get; private set; } = new();
public event Action? OnChange;
public void AddTodo(string title)
{
Items.Add(new TodoItem { Title = title, Id = Guid.NewGuid() });
NotifyStateChanged();
}
public void ToggleComplete(Guid id)
{
var item = Items.FirstOrDefault(x => x.Id == id);
if (item != null) { item.IsComplete = !item.IsComplete; NotifyStateChanged(); }
}
public void Delete(Guid id)
{
Items.RemoveAll(x => x.Id == id);
NotifyStateChanged();
}
private void NotifyStateChanged() => OnChange?.Invoke();
}Reference:
TaskLoco™ — The Sticky Note GOAT