In a WPF MVVM solution, I am using a backgroundworker in order to show a busyindicator while fetching some data and populating a (telerik) treeview. I'm trying to do this when my (parent) usercontrol (holding the TreeView and the RadBusyIndicator) is loaded:
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
BackgroundWorker bg = new BackgroundWorker();
bg.DoWork += (object sender_, DoWorkEventArgs e_) =>
{
GetData();
};
bg.RunWorkerCompleted += (object sender_, RunWorkerCompletedEventArgs e_) =>
{
TreeView.ExpandAll();
IsBusy = false;
};
IsBusy = true;
bg.RunWorkerAsync();
}
The data fetching works just fine and the itemssource for the treeview is set normally.
Everything works fine except for the TreeView.ExpandAll()
.
XAML code:
<telerik:RadTreeView x:Name="TreeView" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" SelectionMode="Single" ItemTemplate="{StaticResource OrderTemplate}" ItemsSource="{Binding Orders, Mode=OneWay}" SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}" telerik:TreeViewPanel.TreeVirtualizationMode="Recycling" >
The top node of the treeview appears but the underlying items are not expanded. I have to click them open (that works fine). Any idea why the treeview is not expanding? What can I do to make this work?