Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DropAdornerTemplateSelector overridden by DragAdornerTemplate #327

Closed
uecasm opened this issue Jul 30, 2019 · 0 comments · Fixed by #393
Closed

DropAdornerTemplateSelector overridden by DragAdornerTemplate #327

uecasm opened this issue Jul 30, 2019 · 0 comments · Fixed by #393
Labels
Milestone

Comments

@uecasm
Copy link

uecasm commented Jul 30, 2019

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
@punker76 punker76 added the Bug label Aug 20, 2021
@punker76 punker76 added this to the 2.4.1 milestone Sep 7, 2021
punker76 added a commit that referenced this issue Sep 7, 2021
Fix using correct template or template selector for source and target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants