Skip to content

Commit 55582e3

Browse files
ES-975464 - Resolve the ReadMe file length issue in this sample repository
1 parent e447055 commit 55582e3

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,37 @@
22

33
## About the example
44

5-
This example illustrates how to populate child nodes asynchronously in uwp treegrid
5+
This example illustrates how to populate child nodes asynchronously in `UWP TreeGrid`.
6+
7+
You can populate the child nodes asynchronously using `async` and `await` at runtime when retrieving data from web services or any database. This can be performed by `PopulateChildNodes` method from `TreeGridRequestTreeItemsEventArgs.ParentNode` property.
8+
9+
``` c#
10+
private async void TreeGrid_RequestTreeItems(object sender, TreeGridRequestTreeItemsEventArgs args)
11+
{
12+
if (args.ParentItem == null)
13+
{
14+
args.ChildItems = viewModel.Employees.Where(x => x.ReportsTo == -1);
15+
}
16+
//if ParentItem not null, then set args.ChildList to the child items for the given ParentItem.
17+
else
18+
{
19+
EmployeeInfo ems = args.ParentItem as EmployeeInfo;
20+
21+
if (ems != null)
22+
{
23+
await Task.Run(async () =>
24+
{
25+
await this.treeGrid.Dispatcher.RunAsync(CoreDispatcherPriority.High, async() =>
26+
{
27+
//Get the child items with time delay
28+
var childItems = await viewModel.GetEmployees(ems.ID);
29+
30+
//Populate the child nodes based on the child items
31+
args.ParentNode.PopulateChildNodes(childItems);
32+
});
33+
34+
});
35+
}
36+
}
37+
}
38+
```

0 commit comments

Comments
 (0)