Back to Devexpress

ResourceTreeControl.TreeListViewStyle Property

wpf-devexpress-dot-xpf-dot-scheduling-dot-resourcetreecontrol-643d56c9.md

latest3.3 KB
Original Source

ResourceTreeControl.TreeListViewStyle Property

Gets or sets a TreeListView style that is applied to the Resource Tree. This is a dependency property.

Namespace : DevExpress.Xpf.Scheduling

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

NuGet Package : DevExpress.Wpf.Scheduling

Declaration

csharp
public Style TreeListViewStyle { get; set; }
vb
Public Property TreeListViewStyle As Style

Property Value

TypeDescription
Style

A Style object providing corresponding style settings.

|

Remarks

Target type: DevExpress.Xpf.Grid.TreeListView.

The example below illustrates how to use the TreeListViewStyle to show images for ResourceTree’s items.

xaml
<local:TreeNodeTypeImageSelector x:Key="imageSelector" Icon1="{dx:DXImage Image=Add_16x16.png}" Icon2="{dx:DXImage Image=Remove_16x16.png}" Icon3="{dx:DXImage Image=Delete_16x16.png}"/>
<!---->
 <dxsch:ResourceTreeControl.TreeListViewStyle>
    <Style TargetType="dxg:TreeListView">
        <Setter Property="ShowNodeImages" Value="True"/>
        <Setter Property="NodeImageSelector" Value="{StaticResource imageSelector}"/>
    </Style>
</dxsch:ResourceTreeControl.TreeListViewStyle>
csharp
public class TreeNodeTypeImageSelector : TreeListNodeImageSelector {
    public ImageSource Icon1 { get; set; }
    public ImageSource Icon2 { get; set; }
    public ImageSource Icon3 { get; set; }

    public override ImageSource Select(TreeListRowData rowData) {
        var value = (ResourceItem)rowData.Row;
        DataType node = value.SourceObject as DataType;
        if (null != node){
            if (node.Id == 1)
                return Icon1;
            if (node.Id == 2)
                return Icon2;
            if (node.Id == 3)
                return Icon3;
        }
        return null;
    }
}
vb
Public Class TreeNodeTypeImageSelector
    Inherits TreeListNodeImageSelector

    Public Property Icon1() As ImageSource
    Public Property Icon2() As ImageSource
    Public Property Icon3() As ImageSource

    Public Overrides Function [Select](ByVal rowData As TreeListRowData) As ImageSource
        Dim value = CType(rowData.Row, ResourceItem)
        Dim node As DataType = TryCast(value.SourceObject, DataType)
        If Nothing IsNot node Then
            If node.Id = 1 Then
                Return Icon1
            End If
            If node.Id = 2 Then
                Return Icon2
            End If
            If node.Id = 3 Then
                Return Icon3
            End If
        End If
        Return Nothing
    End Function
End Class

See Also

ResourceTreeControl Class

ResourceTreeControl Members

DevExpress.Xpf.Scheduling Namespace