---
title: "What’s New in 2021 Volume 1: WPF TreeView"
published_at: "2021-04-12T10:30:00+00:00"
modified_at: "2025-04-22T12:38:24+00:00"
url: "https://www.syncfusion.com/blogs/post/whats-new-in-2021-volume-1-wpf-treeview"
excerpt: "The Syncfusion WPF TreeView control displays hierarchical data in a tree-like structure with expand and collapse node options. It’s rich feature set includes data binding, unbound node population, template selector, drag and drop, selection with different selection modes, complete UI..."
taxonomy_category:
  - "Desktop"
  - "UI"
  - "What's new"
  - "WPF"
taxonomy_post_tag:
  - "desktop"
  - "TreeView"
  - "UI"
  - "What's New"
  - "WPF"
  - "XAML"
---

# What’s New in 2021 Volume 1: WPF TreeView

[Neelakandan Kannan](https://www.syncfusion.com/blogs/author/neelakandan-kannan)

![What's New in 2021 Volume 1: WPF TreeView](https://www.syncfusion.com/blogs/wp-content/uploads/2021/04/Whats-New-in-2021-Volume-1-WPF-TreeView.png)


The Syncfusion [WPF TreeView](https://www.syncfusion.com/wpf-controls/treeview)
 control displays hierarchical data in a tree-like structure with expand and collapse node options. It’s rich feature set includes data binding, unbound node population, template selector, drag and drop, selection with different selection modes, complete UI customization, commands for MVVM and more. We have added the following new user-friendly features in the WPF TreeView in our [2021 Volume 1 release](https://www.syncfusion.com/forums/164043/essential-studio-2021-volume-1-release-v19-1-0-54-is-available-for-download)
:

- [Cancel editing on Esc keypress](#cancel-the-editing-on-esc-key-press) .
- [Enter edit mode on tap](#enter-to-edit-mode-on-tap) .
- [Expand or collapse nodes based on property in underlying data object](#expand-or-collapse-nodes-based-on-property-in-underlying-data-object) .

## Cancel editing on Esc keypress

Typically, users expect to roll back edited changes in a node by pressing the **Esc** key. Now, the WPF TreeView provides support to revert the edited text by implementing the [IEditableObject](https://msdn.microsoft.com/en-us/library/system.componentmodel.ieditableobject.aspx)
 interface to the underlying object.

The user should back up the existing data in a node using the [BeginEdit](https://msdn.microsoft.com/en-us/library/system.componentmodel.ieditableobject.beginedit.aspx)
 method. Then, the backed-up data should be restored in the [CancelEdit](https://msdn.microsoft.com/en-us/library/system.componentmodel.ieditableobject.canceledit.aspx)
 method to roll back the changes.

Refer to the following code example.

```
public class Country : INotifyPropertyChanged, IEditableObject
{
    private bool isSelected;
    internal string name;
    private ObservableCollection<State> states;
    internal Country backUpData;
    private Country currentData;

    public Country()
    {
	
    }

    public Country(string name):base()
    {
        this.currentData = new Country();
        this.currentData.name = name;
        this.currentData.isSelected = false;
    }

    public ObservableCollection<State> States
    {
        get 
        { 
            return states; 
        }
        set
        {
            states = value;
            RaisedOnPropertyChanged("States");
        }
    }

    public string Name
    {
        get
        { 
            return this.currentData.name; 
        }
        set
        {
            this.currentData.name = value;
            RaisedOnPropertyChanged("Name");
        }
    }

    public bool IsSelected
    {
        get 
        { 
            return this.currentData.isSelected; 
        }
        set
        {
            this.currentData.isSelected = value;
            RaisedOnPropertyChanged("IsSelected");
        }
    }

    public event PropertyChangedEventHandler PropertyChanged;

    public void RaisedOnPropertyChanged(string _PropertyName)
    {
        if (PropertyChanged != null)
        {
            PropertyChanged(this, new PropertyChangedEventArgs(_PropertyName));
        }
    }

    public void BeginEdit()
    {
        Debug.WriteLine("BeginEdit is Called.");
        backUpData = new Country();
        backUpData.name = this.currentData.name;
        backUpData.isSelected = this.currentData.isSelected;
    }

    public void CancelEdit()
    {
        Debug.WriteLine("CancelEdit is Called.");
        this.currentData = backUpData;
    }

    public void EndEdit()
    {
        Debug.WriteLine("EndEdit is Called.");
    }
}
```

![Reverting to Original Value on Pressing Esc](https://www.syncfusion.com/blogs/wp-content/uploads/2021/04/Reverting-to-Original-Value-on-Pressing-Esc-1.gif)

Reverting to Original Value on Pressing Esc

## Enter edit mode on tap

By default, the WPF TreeView nodes enter into edit mode on pressing the **F2** key. Users can now edit nodes by tapping or double-tapping them based on the [EditTrigger](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeView.SfTreeView.html#Syncfusion_UI_Xaml_TreeView_SfTreeView_EditTrigger)
 settings.

Refer to the following code example.

```
<syncfusion:SfTreeView x:Name="sfTreeView" 
                       ItemsSource="{Binding Countries}"
                       AllowEditing="True"
                       EditTrigger="DoubleTap"/>
```

![Editing the Value of a Node in the WPF TreeView](https://www.syncfusion.com/blogs/wp-content/uploads/2021/04/Editing-the-Value-of-a-Node-in-the-WPF-TreeView-1.gif)

Editing the Value of a Node in the WPF TreeView

## Expand or collapse nodes based on property

Now, you can control the expand and collapse state of the WPF Treeview nodes during the initial load and at run time. This can be done by setting the property name which holds the expand state in the underlying data object through the [IsExpandedPropertyName](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeView.Engine.HierarchyPropertyDescriptor.html#Syncfusion_UI_Xaml_TreeView_Engine_HierarchyPropertyDescriptor_IsExpandedPropertyName)
 property.

Refer to the following code example.

```
xmlns:treeviewengine="clr-namespace:Syncfusion.UI.Xaml.TreeView.Engine;assembly=Syncfusion.SfTreeView.WPF"

<syncfusion:SfTreeView x:Name="treeView"
         ItemsSource="{Binding Folders}">
    <syncfusion:SfTreeView.HierarchyPropertyDescriptors>        
        <treeviewengine:HierarchyPropertyDescriptor IsExpandedPropertyName="IsExpanded" ChildPropertyName="Cities" TargetType="{x:Type local:State}" />
    </syncfusion:SfTreeView.HierarchyPropertyDescriptors>
</syncfusion:SfTreeView>
```

## Conclusion

Thanks for reading! I hope you now have a clear idea of the new features included in the Syncfusion [WPF TreeView](https://www.syncfusion.com/wpf-controls/treeview)
 control in the [2021 Volume 1](https://www.syncfusion.com/forums/164043/essential-studio-2021-volume-1-release-v19-1-0-54-is-available-for-download)
 release. For more updates on this control and others, refer to our [release notes](https://help.syncfusion.com/common/essential-studio/release-notes/v19.1.0.54)
 and [What’s New pages](https://www.syncfusion.com/products/whatsnew)
.

Browse through our [WPF documentation](https://help.syncfusion.com/wpf/welcome-to-syncfusion-essential-wpf)
 to learn more about our WPF controls. Also, don’t miss our [WPF Project examples](https://github.com/syncfusion/wpf-demos)
.

If you aren’t our customer yet, you can try our 30-day [free trial](https://www.syncfusion.com/downloads)
 to check out these features.

Also, if you wish to send us feedback or would like to submit any questions, please feel free to post them in the comments section of this blog post. You can also contact us through our [support forums](https://www.syncfusion.com/forums)
, [feedback portal](https://www.syncfusion.com/feedback)
, or [Direct-Trac support system](https://www.syncfusion.com/support/directtrac/incidents)
. We are always happy to assist you!

If you like this blog post, we think you’ll also like the following articles too:

- [What’s New in 2021 Volume 1 : WPF](https://www.syncfusion.com/blogs/post/whats-new-in-2021-volume-1-wpf.aspx) [Blog]
- [3 Steps to Lazy Load Data in WPF TreeView in MVVM Pattern](https://www.syncfusion.com/blogs/post/3-steps-to-lazy-load-data-in-wpf-treeview-mvvm.aspx) [Blog]
- [WPF Debugging and Performance Succinctly](https://www.syncfusion.com/succinctly-free-ebooks/wpf-debugging-and-performance) [Ebook]
- [WPF Succinctly](https://www.syncfusion.com/succinctly-free-ebooks/wpf-succinctly) [Ebook]
