Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
XAML TreeView
WhatsApp
Mahesh Chand
6y
104.3k
0
6
100
Article
The XAML TreeView element represents a TreeView control in WPF. The code in this article are examples of using a XAML TreeView element.
XAML TreeView element to declare the TreeView control.
<
TreeView
Margin
=
"10,10,0,13"
Name
=
"TreeView1"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
Width
=
"194"
Height
=
"200"
/>
A TreeView is a collection of TreeViewItem elements. The following XAML code adds a few TreeViewItem element to the control.
<TreeView
Margin
=
"10,10,0,13"
Name
=
"TreeView1"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
Width
=
"194"
Height
=
"200"
>
<
TreeViewItem
Header
=
"Cold Drinks"
>
<
TreeViewItem
Header
=
"Coke"
>
</
TreeViewItem
>
<
TreeViewItem
Header
=
"Pepsi"
>
</
TreeViewItem
>
<
TreeViewItem
Header
=
"Orange Juice"
>
</
TreeViewItem
>
<
TreeViewItem
Header
=
"Milk"
>
</
TreeViewItem
>
<
TreeViewItem
Header
=
"Iced Tea"
>
</
TreeViewItem
>
<
TreeViewItem
Header
=
"Mango Shake"
>
</
TreeViewItem
>
</
TreeViewItem
>
</
TreeView
>
You can write a double click event handler on a TreeViewItem to execute some code when a TreeView item is double clicked.
<
TreeViewItem
Header
=
"Dad"
Foreground
=
"Blue"
MouseDoubleClick
=
"TreeViewItem_MouseDoubleClick"
>
And implement event handler in your code behind.
private void TreeViewItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
}
To avoid duplicate content, the article has moved here:
WPF TreeView Tutorial
Learn XAML
TreeView
WPF
XAML
XAML TreeView in WPF
Up Next
Ebook Download
View all
Programming XAML
Read by 12.3k people
Download Now!
Learn
View all
Mindcracker
Founded in 2003, Mindcracker is the authority in custom software development and innovation. We put best practices into action. We deliver solutions based on consumer and industry analysis.
Membership not found