Back to Devexpress

TreeListView.ExpandStateBinding Property

wpf-devexpress-dot-xpf-dot-grid-dot-treelistview-a1ca0cad.md

latest3.1 KB
Original Source

TreeListView.ExpandStateBinding Property

Gets or sets the binding that determines which nodes are expanded.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public Binding ExpandStateBinding { get; set; }
vb
Public Property ExpandStateBinding As Binding

Property Value

TypeDescription
Binding

A Binding object specifying which nodes are expanded.

|

Remarks

xaml
<Window.Resources>
    <local:ExpandedConverter x:Key="expandedConverter"/>
</Window.Resources>
<dxg:TreeListControl ItemsSource="{Binding Employees}" 
                     AutoGenerateColumns="AddNew" 
                     EnableSmartColumnsGeneration="True">
    <dxg:TreeListControl.View>
        <dxg:TreeListView KeyFieldName="ID" 
                          ParentFieldName="ParentID" 
                          ExpandStateBinding="{Binding Position, Converter={StaticResource expandedConverter}}"/>
    </dxg:TreeListControl.View>
</dxg:TreeListControl>
csharp
public class ExpandedConverter : IValueConverter {
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
        if (value.ToString() == "President")
            return true;
        return false;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
        throw new NotImplementedException();
    }
}
vb
Public Class ExpandedConverter
    Inherits IValueConverter

    Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object
        If value.ToString() = "President" Then Return True
        Return False
    End Function

    Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object
        Throw New NotImplementedException()
    End Function
End Class

See Also

ExpandStateBinding

Expand and Collapse Nodes

TreeListView Class

TreeListView Members

DevExpress.Xpf.Grid Namespace