Skip to main content

TreeListView.NodeImageSelector Property

Gets or sets a selector that chooses a node image based on custom logic. This is a dependency property.

Namespace: DevExpress.Xpf.Grid

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

NuGet Package: DevExpress.Wpf.Grid.Core

Declaration

public TreeListNodeImageSelector NodeImageSelector { get; set; }

Property Value

Type Description
DevExpress.Xpf.Grid.TreeListNodeImageSelector

A DevExpress.Xpf.Grid.TreeListNodeImageSelector descendant that chooses a node image based on custom logic.

Remarks

Run Demo: End-User Customization

The following code sample demonstrates how to use the NodeImageSelector to display different images based on the node level:

NodeImageSelector

<Window.Resources>
    <local:EmployeeTaskImageSelector x:Key="taskImageSelector"/>  
</Window.Resources>
<Grid>
    <dxg:TreeListControl ...>
        <!-- ... -->
        <dxg:TreeListControl.View>
            <dxg:TreeListView ...
                              ShowNodeImages="True"
                              NodeImageSelector="{StaticResource taskImageSelector}">                   
            </dxg:TreeListView>
        </dxg:TreeListControl.View>
    </dxg:TreeListControl>
</Grid>
public class EmployeeTaskImageSelector : DevExpress.Xpf.Grid.TreeListNodeImageSelector {
    static ImageSource GetSvgImage(string imageName) {
        var extension = new SvgImageSourceExtension() { 
            Uri = new Uri(string.Format("pack://application:,,,/IsReadOnlyBindingExample;component/Images/{0}.svg", imageName)), 
            Size = new System.Windows.Size(16, 16)
        };
        return (ImageSource)extension.ProvideValue(null);
    }
    static List<ImageSource> TaskImages;
    static EmployeeTaskImageSelector() {
        TaskImages = new List<ImageSource>();
        TaskImages.Add(GetSvgImage("Task"));
        TaskImages.Add(GetSvgImage("Note"));
    }
    public override ImageSource Select(TreeListRowData rowData) {
        if(rowData.Level == 0)
            return TaskImages[0];
        return TaskImages[1];
    }
}

Note

An image specified by the TreeListNode.Image property takes priority over an image specified by the NodeImageSelector.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the NodeImageSelector property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also