I need a control that behaves like a treeview (binds to a tree structure, expands child nodes based on IsExpanded property of bound object), yet displays data like the grid (no indenting, or toggle images).
The expand collapse will be happening automatically based on bound object.
TreeView is perfect, i just need to remove the indentation and the triangle image to make it vertically flat, like a grid column.
I suppose i could try overriding the TreeViewItem template, but that just doesn't display anything..
Based on the TreeView
style on MSDN, something like this should work:
<Style TargetType="TreeViewItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TreeViewItem">
<StackPanel>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="ExpansionStates">
<VisualState x:Name="Expanded">
<Storyboard>
<ObjectAnimationUsingKeyFrames
Storyboard.TargetProperty="(UIElement.Visibility)"
Storyboard.TargetName="ItemsHost">
<DiscreteObjectKeyFrame KeyTime="0"
Value="{x:Static Visibility.Visible}" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Collapsed" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentPresenter ContentSource="Header" />
<ItemsPresenter Name="ItemsHost" Visibility="Collapsed" />
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With