The following quick start guide is intended to get you up and running with C1TreeView. In this quick start, you'll start in Visual Studio to create a new project, add a C1TreeView control to your application, add C1TreeViewItems and customize the control.
XAML |
Copy Code
|
---|---|
<Grid> <c1:C1TreeView></c1:C1TreeView> </Grid> |
Give your grid a name by adding x:Name="Tree" to the <c1:C1TreeView> tag so that it appears similar to the following:
XAML |
Copy Code
|
---|---|
<c1:C1TreeView Name="Tree">
|
By giving the control a unique identifier, you'll be able to access the C1TreeView control in code.
You've successfully created a WPF application containing a C1TreeView control. In the next step, you will add C1TreeViewItems to the C1TreeView control.
In this step, we share two different ways to add C1TreeViewItems to the C1TreeView control in XAML markup and in code.
In XAML
To add static C1TreeViewItems to the C1TreeView control in the XAML:
XAML |
Copy Code
|
---|---|
<c1:C1TreeViewItem Header="Book List"></c1:C1TreeViewItem>
|
XAML |
Copy Code
|
---|---|
<c1:C1TreeViewItem Header="Language Books"/> <c1:C1TreeViewItem Header="Security Books"/> |
XAML |
Copy Code
|
---|---|
<c1:C1TreeViewItem Header="Classic Books"> <c1:C1TreeViewItem Header="Catch-22"/> <c1:C1TreeViewItem Header="The Great Gatsby"/> </c1:C1TreeViewItem> |
Include the following XAML markup in your file:
XAML |
Copy Code
|
---|---|
<Grid> <c1:C1TreeView Name="Tree" > <c1:C1TreeViewItem Header="Book List"> <c1:C1TreeViewItem Header="Language Books"/> <c1:C1TreeViewItem Header="Security Books"/> <c1:C1TreeViewItem Header="Classic Books"> <c1:C1TreeViewItem Header="Catch-22"/> <c1:C1TreeViewItem Header="The Great Gatsby"/> </c1:C1TreeViewItem> </c1:C1TreeViewItem> </c1:C1TreeView> </Grid> |
In Code
To add static C1TreeViewItems to the C1TreeView control in the code behind file instead, add the following code in the Code Editor:
In the previous step you worked in Visual Studio to create C1TreeViewItems in XAML. In this step you'll customize the C1TreeView control's appearance and behavior in Visual Studio using XAML code.
Within the <c1:C1TreeView> tag add SelectionMode="Extended". This will create a top-level node that you will be able to select multiple tree items by holding the shift and control keys. The XAML markup appears as follows:
XAML |
Copy Code
|
---|---|
<c1:C1TreeView x:Name="Tree" SelectionMode="Extended"> |
Within the <c1:C1TreeViewItem> add the tag IsExpanded="True" and IsSelected="True". This will create a top-level node that appears selected and expanded at run time. The XAML markup appears as follows:
XAML |
Copy Code
|
---|---|
<c1:C1TreeViewItem Header="Book List" IsExpanded="True" IsSelected="True"> |
XAML |
Copy Code
|
---|---|
<c1:C1TreeViewItem Header="Language Books" Foreground="Fuchsia"/> |
Congratulations!
You have successfully completed the TreeView for WPF quick start. In this quick start, you've created and customized a TreeView for WPF application, added static C1TreeViewItems, and observed several of the control's run-time features.