wpf treeview ObjectDataProvider update - how?
- by wonea
I've been having trouble updating the data bindings which relates to a treeview. The dataset is mapped onto the ObjectDataProvider, passed through two data templates. Now I've tried updating the ObjectDataProvider with two calls, hoping that they would trigger the CreateTheDataSet() method, and rebuild the tree.
Tried calling;
thetreeView.ItemTemplate.LoadContent();
thetreeView.Items.Refresh();
Program code;
<Window.Resources>
<ObjectDataProvider
x:Key="dataSetProvider"
MethodName="CreateDataSet"
ObjectType="{x:Type local:DataSetCreator}" />
<DataTemplate x:Key="DetailTemplate">
<TextBlock Text="{Binding Path=personname}" />
</DataTemplate>
<HierarchicalDataTemplate x:Key="MasterTemplate"
ItemsSource="{Binding Master2Detail}"
ItemTemplate="{StaticResource DetailTemplate}">
<TextBlock Text="{Binding Path=jobname}" />
</HierarchicalDataTemplate>
</Window.Resources>
<x:Name="thetreeView"
DataContext="{StaticResource dataSetProvider}"
ItemsSource="{Binding compMaster}"
ItemTemplate="{StaticResource MasterTemplate}" />
My dataset creation class;
public static class DataSetCreator
{
public static DataSet CreateTheDataSet()
{
DataSet dataset = new DataSet();
// Create dataset ... blah blah
return dataset;
}
}