Open uecasm opened 5 years ago
I can partially solve the third problem by moving the DragDrop
properties to the Header
of the TabItem
rather than on the TabItem
itself -- ie. the second TabItem
becomes:
<TabItem>
<TabItem.Header>
<TextBlock Text="Group Two"
dd:DragDrop.IsDropTarget="True"
dd:DragDrop.DropHandler="{Binding}"
dd:DragDrop.ShowAlwaysDropTargetAdorner="True"
dd:DragDrop.DropAdornerTemplate="{StaticResource DragToGroup2Template}" />
</TabItem.Header>
<ListBox Margin="5" ItemsSource="{Binding Group2}" HorizontalContentAlignment="Stretch"
dd:DragDrop.IsDragSource="True" dd:DragDrop.IsDropTarget="True"
dd:DragDrop.DropHandler="{Binding}"
dd:DragDrop.DragDirectlySelectedOnly="True"
dd:DragDrop.DragAdornerTemplate="{StaticResource DragItemTemplate}"
dd:DragDrop.UseDefaultEffectDataTemplate="True" />
</TabItem>
(Also need to change TabItem
to TextBlock
in the DragOver
handler. In real code this probably should be done a different way, eg. by using a different DropHandler
.)
You can see this change at https://github.com/uecasm/gong-test-1/tree/textblock-header.
This fixes the problem of the wrong Drag adorner being displayed while dragging an item from group 2's listbox around inside that listbox.
However it still displays that adorner when dragging an item from group 2's list over the group 2 tab header, which I don't want. (The effect adorner appears to be smart enough to hide itself for that case.)
Part one is fixed and available with v2.0.6
It's possible that some of this is already solvable using existing features of the library, but there really isn't much documentation for it, and even reading the code it can be hard to understand what some properties are for. (It would also be nice if you provided a pre-compiled Release of the Showcase app, so that people don't have to install additional tools to compile it themselves.)
A pre-compiled showcase app is available on every release https://github.com/punker76/gong-wpf-dragdrop/releases
Configurable effects adorner would be amazing! I think have the same use case - I want to provide a short explanation tooltip about why a drag-drop operation is invalid (due to constraints placed on which items can be copied to other lists).
I can achieve this with the default effect data template, because I can supply the contextual information from the ViewModel in the form of effect text and destination text. However there's no way to configure the look and feel to match my app.
The only alternatives are to supply a custom drop target adorner to render a tooltip, (which almost works, except the adorner is clipped at the boundaries of the element I'm dragging to), or else to use an EffectAdornerTemplate (in which case I can't dynamically set the text).
I'd be happy to do the work and create a P/R, but I have no idea where to start. Any suggestions?
So I've had a look over the past few days, and after learning a bunch of stuff about WPF which I haven't needed to know until now, I have a solution of sorts. I'm not sure if it's good practice or not though, it certainly seems a bit hacky to me. What I did:
adornment.Tag = dropInfo;
dd:DragDrop.EffectMoveAdornerTemplate="{DynamicResource MoveEffectAdornerTemplate}"
Text="{Binding Path=Tag.EffectText, RelativeSource={RelativeSource TemplatedParent}}"
My adorner resource then looks like this: `
What steps will reproduce this issue?
[x] The first problem is that the Effect adorner gets clipped at the window edges; this appears to have been previously solved for the Drag adorner (#69), so perhaps that existing solution just needs to be applied to both?
[ ] The second problem is a more general one that the Effect adorner doesn't appear to be template-customisable based on the drop target (other than supplying
EffectText
andDestinationText
, which in turn can't be used in a purely XAML template). This might be a "too hard basket" issue to actually solve for now, but bears mentioning.[x] The third problem is that (after switching to use the Drag adorner instead of the Effect adorner due to the above two problems), the Drag adorner ends up being displayed inappropriately in the case when dragging items inside the second tab.
Expected outcome
More explanation of the intended and observed behaviour can be found in the readme in the repository below.
It's possible that some of this is already solvable using existing features of the library, but there really isn't much documentation for it, and even reading the code it can be hard to understand what some properties are for. (It would also be nice if you provided a pre-compiled Release of the Showcase app, so that people don't have to install additional tools to compile it themselves.)
Repo
https://github.com/uecasm/gong-test-1
Environment