question

JuliusMax-5469 avatar image
0 Votes"
JuliusMax-5469 asked HuiLiu-MSFT commented

How to remove the root node from TreeView bound to DataSet With HierarchicalDataTemplate

Good evening,

I Have the working code XAML + Powershell:

<TabItem Header="Tasks" Visibility="Collapsed" Name="TabTasks">
<TabItem.Resources>
<HierarchicalDataTemplate x:Key="ClosuresDataTemplate" ItemsSource="{Binding Status2Closure}" >
<Grid>
<CheckBox IsChecked="True" Content="{Binding TaskStatus}"/>
<CheckBox IsChecked="True" Content="{Binding TaskClosure}"/>
</Grid>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="StatusDataTemplate" ItemsSource="{Binding Types2Status}" ItemTemplate="{StaticResource ClosuresDataTemplate}">
<CheckBox IsChecked="True" Content="{Binding TaskType}"/>
</HierarchicalDataTemplate>
<HierarchicalDataTemplate x:Key="TypesDataTemplate" ItemsSource="{Binding TasksTypes}" ItemTemplate="{StaticResource StatusDataTemplate}">
<TextBlock Text="Task types, status and closure reason tree"/>
</HierarchicalDataTemplate>
</TabItem.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="20"/>
<RowDefinition Height="20"/>
<RowDefinition Height="20"/>
<RowDefinition Height="250"/>
<RowDefinition Height="20"/>
<RowDefinition Height="250"/>
<RowDefinition Height="20*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1000*"/>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<TreeView Name="TreeTest" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="1" Grid.RowSpan="6" HorizontalContentAlignment="Stretch" Background="LightSlateGray" ItemTemplate="{StaticResource TypesDataTemplate}"/>
</Grid>
</TabItem>

Data send by PS with:
$wpf.TreeTest.ItemsSource = $dts.DefaultViewManager

$dts is a DataSet with 3 tables and 2 relations on primary keys.
This works but I get a useless root node for "TypesDataTemplate". I tried to plug the treeview to"StatusDataTemplate" but then nothing appear anymore.
I'm bit confused about what is happening there.



windows-server-powershelldotnet-wpf-xaml
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,@ JuliusMax-5469. Could you show me the expanded node graph of your treeview and indicate the node to be removed? And can you show me the code of your DataSet?

0 Votes 0 ·

0 Answers