wpf treeview ObjectDataProvider update - how?
Posted
by wonea
on Stack Overflow
See other posts from Stack Overflow
or by wonea
Published on 2010-05-13T15:49:32Z
Indexed on
2010/05/13
15:54 UTC
Read the original article
Hit count: 956
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;
}
}
© Stack Overflow or respective owner