question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Listbox horizontal line not showing

See original GitHub issue

I can’t figure it out why the gray horizontal line does not show when dragging items to ListBox. Is there some trick here?

<Window x:Class="EmptyListBoxWithDragAndDrop.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:gong="clr-namespace:GongSolutions.Wpf.DragDrop;assembly=GongSolutions.Wpf.DragDrop"
        Title="MainWindow" Height="600" Width="800" WindowStartupLocation="CenterScreen">

    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>

        <ListBox Grid.Column="0" ItemsSource="{Binding Source}"
                 gong:DragDrop.IsDragSource="True" gong:DragDrop.UseDefaultEffectDataTemplate="True"/>

        <ListBox Grid.Column="1" ItemsSource="{Binding Target}" 
                 gong:DragDrop.IsDropTarget="True" gong:DragDrop.DropHandler="{Binding}">
            <ListBox.Style>
                <Style  TargetType="ListBox" BasedOn="{StaticResource {x:Type ListBox}}">
                    <Style.Triggers>
                        <Trigger Property="HasItems" Value="False">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate>
                                        <TextBlock Text="Drag items from left ListBox" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </ListBox.Style>
        </ListBox>
    </Grid>
</Window>

I even remove the trigger style, but it doesn’t work, no horizontal line is shown. This is the line I’m talking about:

untitled

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
JobaDinizcommented, Aug 25, 2016

Is there some trick here?

So there is a catch 😄 Thanks, it worked!

And you should give your custom template a background to allow target drop at the whole client size

I can’t believe it! Thanks a lot, I’ve been banging my head over this (my stackoverflow question)

2reactions
punker76commented, Aug 25, 2016

@JobaDiniz 😄 I should use a default for this to avoid such issues…

public void DragOver(IDropInfo dropInfo)
{
    // you must say which adorner you want if you implement the IDropTarget interface
    dropInfo.DropTargetAdorner = DropTargetAdorners.Insert;
    // or you call the DragOver method from the default DefaultDropHandler to get the adorner
    //GongSolutions.Wpf.DragDrop.DragDrop.DefaultDropHandler.DragOver(dropInfo);

    if (dropInfo.Data is string)
        dropInfo.Effects = System.Windows.DragDropEffects.Copy;
}

2016-08-25_16h12_07

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to place a horizontal line after each item in listbox
Check this:.
Read more >
Listbox Horizontal scrollbar not visible - Getting Started
But the Listbox Horizontal scrollbar is not visible, and it is set to true for visible. I made sure the count changed from...
Read more >
Horizontal lines every second row in listbox - Windows
I've just gotten a report from a Windows test user that all of the listboxes in my app have a white horizontal line...
Read more >
Horizontal lines - QlikView App Dev
Hi All, Has anyone else noticed that Horizontal lines with 1-2pt aren't ... reference line not showing properly - when bar chart orientation...
Read more >
Solved: Horizontal Line - Qlik Community - 535496
Hi all,. It is possible in my chart to create a symetric courbe like a pink exponential courbe and it is possible to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found