--- title: "How to: Create Simple or Complex TreeViews" ms.date: "03/30/2017" helpviewer_keywords: - "TreeView control [WPF], creating" - "Control class [WPF], TreeView [WPF], creating" ms.assetid: 1defbb78-b8e7-4c0e-b650-576453ac828d --- # How to: Create Simple or Complex TreeViews This example shows how to create simple or complex controls. A consists of a hierarchy of controls, which can contain simple text strings and also more complex content, such as controls or a with embedded content. You can explicitly define the content or a data source can provide the content. This topic provides examples of these concepts. ## Example The property of the contains the content that the displays for that item. A can also have controls as its child elements and you can define these child elements by using the property. The following example shows how to explicitly define content by setting the property to a text string. [!code-xaml[TreeViewSimple#1](~/samples/snippets/csharp/VS_Snippets_Wpf/TreeViewSimple/CS/Window1.xaml#1)] The following example show how to define child elements of a by defining that are controls. [!code-xaml[TreeViewSimple#3](~/samples/snippets/csharp/VS_Snippets_Wpf/TreeViewSimple/CS/Window1.xaml#3)] The following example shows how to create a where an provides content and a defines the appearance of the content. [!code-xaml[TreeViewSimple#6](~/samples/snippets/csharp/VS_Snippets_Wpf/TreeViewSimple/CS/Window1.xaml#6)] [!code-xaml[TreeViewSimple#7](~/samples/snippets/csharp/VS_Snippets_Wpf/TreeViewSimple/CS/Window1.xaml#7)] [!code-xaml[TreeViewSimple#5](~/samples/snippets/csharp/VS_Snippets_Wpf/TreeViewSimple/CS/Window1.xaml#5)] The following example shows how to create a where the content contains controls that have embedded content. [!code-xaml[TreeViewSimple#9](~/samples/snippets/csharp/VS_Snippets_Wpf/TreeViewSimple/CS/Window1.xaml#9)] ## See also - - - [TreeView Overview](treeview-overview.md) - [How-to Topics](treeview-how-to-topics.md)