Hi.
Does anyone have a working silverlight client-side example of asynchronously loading data into a RadTreeListView without using ria services?
I have tried the following:
Does anyone have a working silverlight client-side example of asynchronously loading data into a RadTreeListView without using ria services?
I have tried the following:
DataLoadMode="Asynchronous"
IsBusy="{Binding IsBusy}"
<telerik:RadTreeListView.ChildTableDefinitions>
<telerik:TreeListViewTableDefinition ItemsSource="{Binding Items, Mode=TwoWay}" />
</telerik:RadTreeListView.ChildTableDefinitions>
<telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" />
public class PersonViewModel : INotifyPropertyChanged
{public long Id { get; set; }public string Name { get; set; }
public bool IsBusy = false;
private bool childrenLoaded = false;
private ObservableCollection<PersonViewModel> items;
public event PropertyChangedEventHandler PropertyChanged;
private void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public ObservableCollection<PersonViewModel> Items
{get
{
if (!childrenLoaded)
{
this.IsBusy = true;
MyWCFServiceClient client = MyWCFServiceFactory.Create();
client.GetChildrenCompleted += (s, e) =>
{
if (e.Error != null)
{
//TODO: Handle error
return;
}
ObservableCollection<Person> children = e.Result;
this.items = new ObservableCollection<PersonViewModel>();
foreach (Person child in children) {
PersonViewModel personViewModel = new PersonViewModel()personViewModel.Id = child.Id;personViewModel.Name = child.Name;
this.items.Add(personViewModel);
}
childrenLoaded = true;
this.IsBusy = false;
NotifyPropertyChanged("Items");
};
client.GetChildrenAsync(this.Id);
}
return items;
}
}
} But the RadTreeListView does not get updated when NotifyPropertyChanged("Items") is called. I expected the IsBusy indicator to appear during loading, but it did not. I expected the expander\collapser icon to appear after NotifyPropertyChanged("Items") is called, but it did not. Any ideas? Thank you. RadControls_for_Silverlight_4_2010_2_0812