Skip to content

Set custom collections for previews #515

@DasicPhilipp

Description

@DasicPhilipp

I have an implementation of a TreeView, where I have an implementation of multiple selection. However, I cannot configure DragHandler to use my own collection instead of what the inhereted TreeView class offers. I found where the default DragDropPreview determines if it's a collection or not:

private static bool IsMultiSelection(IDragInfo dragInfo)
{
        return dragInfo?.Data is IEnumerable and not string;
}

But I don't see any opportunities to impact on dragInfo.Data. I tried to do it in DragOver() method in my DragHandler implementation:

void IDropTarget.DragOver(IDropInfo dropInfo)
{
        dropInfo.Data = SelectedItems;
        dropInfo.DragInfo.Data = SelectedItems;
}

But it seems like it's too late to set the data here, since it's been already rendered.

Is there any workarounds to achieve the desired behaviour or do we need to change something in the library?

As far as I see, the library relies at MultiSelector class. However, it's not possible to inherit from it since TreeView doesn't support it. My custom implementation still inherits from TreeView, so it seems like I need to fork the library to reinvent it or make a pull request.
https://github.com/punker76/gong-wpf-dragdrop/blob/develop/src/GongSolutions.WPF.DragDrop/Utilities/ItemsControlExtensions.cs#L60

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions