In LoadOnDemandTimer_Tick handler, I want to bind data source object from WCF.
When i add static object it works, but add from WCF node expanding icon is spinning continuously.
private void LoadOnDemandTimer_Tick(object sender, EventArgs e)
{
Department dpt = this.currentTreeViewItem.Item as Department;
Department sub = new Department();
sub.DepartmentName = "sub";
sub.Departmentid = "code";
dpt.Children.Add(sub); //<-- it works fine
TreeViewORGDataSource relSubSource = new TreeViewORGDataSource();
relSubSource.FillByCompayCode(dpt.CompanyCode);
if (relSubSource.Count > 0)
{
foreach (Department item in relSubSource[0].Children)
{
dpt.Children.Add(item);
}
}
this.currentTreeViewItem.IsExpanded = true;
(sender as DispatcherTimer).Stop();
}
FillByCompayCode method is WCF binding method.
I guess the reason is FillByCompayCode method is asyncronous.
How can i it works?