Reputation: 6378
I'm working using WPF, and I'm dealing with the treeViewItem. I'm looking for a way to expand the node when the mouse is over this node, and set IsExpand=false
property when the mouse is not over there. It's quite simple the functionality.
I'm a bit lost using the events for this controls, if should I use the triggers or the events. Thanks in advance.
Upvotes: 0
Views: 1106
Reputation: 43596
Someting like this should point you in the right direction
<Grid>
<TreeView Margin="0,40,0,0">
<TreeViewItem Header="Level 1">
<TreeViewItem Header="Level 2" />
</TreeViewItem>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="False" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="IsExpanded" Value="True" />
</Trigger>
</Style.Triggers>
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
</Grid>
Upvotes: 2