How to use the TreeView Element and loading it through code.
The XAML is as below. We can have any number of nodes in a tree. there is no limit for that Each new TreeViewItem that is added is made into blue color for easy understanding.
</TreeView>
First Node(Hello ) is expanded
The Node inside the node is expanded. (Fourth element)
The Node inside the node inside Node is expanded. (Inside Fourth Node)
The Tree is expanded entirely
The XAML is as below. We can have any number of nodes in a tree. there is no limit for that Each new TreeViewItem that is added is made into blue color for easy understanding.
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
<TreeView>
<TreeViewItem>
<TreeViewItem.Header>
<TextBlock Text ="Hello"></TextBlock>
</TreeViewItem.Header>
<TreeViewItem Header="First element"/>
<TreeViewItem Header="Second element"/>
<TreeViewItem Header="Third element"/>
<TreeViewItem Header="Fourth element">
<TreeViewItem>
<TreeViewItem.Header>
<TextBlock Text ="Inside Fourth"></TextBlock>
</TreeViewItem.Header>
<TreeViewItem Header="Is there an end to this?"/>
</TreeViewItem>
</TreeViewItem>
<TreeViewItem Header="World">
<TreeViewItem Header="Again a first element"/>
</TreeViewItem>
</TreeView>
</Page>
The Output will be as follows:
Both the nodes are not expanded
Both the nodes are not expanded
First Node(Hello ) is expanded
The Node inside the node is expanded. (Fourth element)
The Node inside the node inside Node is expanded. (Inside Fourth Node)
The Tree is expanded entirely
No comments:
Post a Comment