TreeView Control in WPF Window Based
A TreeView Shows data in a hierarchical Form in a parent child relationship where a parent node can be expanded .You can use the TreeView control to display information from a wide variety of data sources such as an XML file, site-map file, string, or from a database. or you can say TreeView control is a hierarchical structure to display the data. its look like a tree. it also contain root node, parent node and child node like tree.
Features:
A TreeView Shows data in a hierarchical Form in a parent child relationship where a parent node can be expanded .You can use the TreeView control to display information from a wide variety of data sources such as an XML file, site-map file, string, or from a database. or you can say TreeView control is a hierarchical structure to display the data. its look like a tree. it also contain root node, parent node and child node like tree.
Features:
- Internet Explorer Favorites style view.
- Append a number to any node, allowing you to create an Outlook style folder list with message counts.
- Choose Font and Color on an item-by-item basis, and set the control's back color.
- Bolding of items
- Info Tip (multi-line tooltip) support with full control over Info Tip color
- Works with Microsoft or API ImageList.
- Item check boxes
- Full-Row select mode
- Single-Click expand mode
- Supports Two Images per item: one standard icon and a state icon.
- Disable Custom Draw for maximum speed
- Speed-optimized Clear method
Example of TreeView Control:
<Window x:Class="WpfApplication7.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="370" Width="417" Loaded="Window_Loaded">
<Grid>
<ListView>
<TreeView Name="tree1" Background="LightCyan" >
<TreeViewItem Header="File" Background="Red" FontSize="15">
</TreeViewItem>
<TreeViewItem Header="Edit" Background="Red" FontSize="15" >
</TreeViewItem>
</TreeView>
</ListView>
</Grid>
</Window>
XAML .CS Code
private void Window_Loaded(object sender, RoutedEventArgs e)
{
Dictionary<string, List<string>> items = new Dictionary<string, List<string>>()
{
{"File",new List<string>() {"New","Open","ADD","Save","Save As","Close"}},
{"Edit",new List<string>() {"Undo","Cut","Copy","Paste","Delete"}},
};
foreach (TreeViewItem tv in tree1.Items)
{
foreach (string item in items[tv.Header.ToString()])
tv.Items.Add(item);
}
}
Designed Output-
No comments:
Post a Comment