Skip to content

DropAdornerTemplateSelector overridden by DragAdornerTemplate #327

Closed

Description

@uecasm

What steps will reproduce this issue?

As a followup to #325 , I tried to use a DropAdornerTemplateSelector to provide some custom logic to select different templates to display in different conditions.

However, because the CreateDragAdorner implementation just uses a nullable pattern for both sets of properties, it ends up passing a non-null DataTemplate (from DragAdornerTemplate) and a non-null DataTemplateSelector (from DropAdornerTemplateSelector).

Due to the way that ContentPresenter works (a template always wins over a template selector), this means that the drop-level template selector is ignored and only the drag-level template is used.

Expected outcome

If a template or template selector are provided at the Drop level, the Drag level properties should not be read (leaving the corresponding variable null).

Also: it would be nice if a public static property were added so that DragDrop.m_DragInfo could be read externally. Among other things, this would allow such a DataTemplateSelector to use the current drag operation to help decide on which template to use. A suggested implementation is:

public static DragInfo CurrentDragInfo
{
    get { return m_DragInProgress ? m_DragInfo : null; }
}

It would also be nice if the DropInfo were similarly available, but that's probably less feasible (and less important). Another possible alternative (which might be much cleaner) is if the DropHandler.DragOver handler could set a template which overrides the standard visual properties.

Repo

https://github.com/uecasm/gong-test-1/tree/drop-template-selector

Environment

  • GongSolutions.WPF.DragDrop 2.0.3
  • Windows 8.1.1
  • Visual Studio 2017
  • .NET Framework 4.6.2

Activity

  1. added this to the 2.4.1 milestone on Sep 7, 2021
  2. added 2 commits that reference this issue on Sep 7, 2021
  3. added a commit that references this issue on Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions