} } } @code { public IEnumerable HierarchicalData { get; set; } public IEnumerable SelectedItems { get; set; } = new List(); public IEnumerable ExpandedItems { get; set; } = new List(); void SelectedItemsHandler(IEnumerable items) { SelectedItems = items; } public class ProductCategoryItem { public string Category { get; set; } public List Products { get; set; } } public class ProductItem { public string ProductName { get; set; } } protected override void OnInitialized() { LoadHierarchical(); ExpandedItems = HierarchicalData.Where(x => x.Products != null && x.Products.Any()).ToList(); } private void LoadHierarchical() { List roots = new List(); List firstCategoryProducts = new List() { new ProductItem { ProductName= "Category 1 - Product 1" }, new ProductItem { ProductName= "Category 1 - Product 2" } }; roots.Add(new ProductCategoryItem { Category = "Category 1", Products = firstCategoryProducts // this is how child items are provided }); roots.Add(new ProductCategoryItem { Category = "Category 2" // we will set no other properties and it will not have children, nor will it be expanded }); HierarchicalData = roots; } }