I have a dataset I created from a Oracle Query. I get a datatable from a function and add it to dataset.
now I try to bind to treeview to the ds. My code Behind:
private void init_TreeView()
{
//TreeViewItem parent = PM_TreeView.Items.Add("Requirements");
DataTable dt = DataBases.RunQuery();
dt.TableName = "REQ";
DataSet ds = new DataSet();
ds.Tables.Add(dt);
//ds.Relations.Add("rsParentChild", ds.Tables["REQ"].Columns["RQ_REQ_ID"], ds.Tables["REQ"].Columns["RQ_FATHER_ID"]);
var dataSet = ds;
_rootNodes = dataSet.Tables["REQ"].DefaultView;
_rootNodes.RowFilter = "RQ_FATHER_ID = -1";
this.DataContext = this;
}
and
private DataView _rootNodes;
and
public DataView RootNodes
{
get { return _rootNodes; }
}
and my XAML:
<TreeView x:Name="PM_TreeView" ItemsSource="{Binding RootNodes}" HorizontalAlignment="Left" Height="445" Margin="44.847,68.285,0,0" VerticalAlignment="Top" Width="320" Foreground="{x:Null}" BorderBrush="{x:Null}" Background="#FFBBB6B6" FontFamily="Segoe UI" FontSize="13.333">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding rsParentChild}">
<TextBlock Text="{Binding NodeDescription}" />
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
my datatable is:
RQ_REQ_ID RQ_FATHER_ID RQ_REQ_NAME
0 -1 REQ
1 0 QC11
but I get nothing on the treeview :)
10x in advance.
<TextBock Text={Binding RootNodes}/>in xaml and see what it is displaying? - D J