Gong-wpf-dragdrop: No se muestra la línea horizontal del cuadro de lista

Creado en 25 ago. 2016  ·  7Comentarios  ·  Fuente: punker76/gong-wpf-dragdrop

No puedo entender por qué la línea horizontal gris no se muestra al arrastrar elementos a ListBox. ¿Hay algún truco aquí?

<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>

Incluso elimino el estilo del disparador, pero no funciona, no se muestra ninguna línea horizontal.
Esta es la línea de la que estoy hablando:

untitled

Comentario más útil

¿Hay algún truco aquí?

Así que hay una trampa: D Gracias, ¡funcionó!

Y debe darle un fondo a su plantilla personalizada para permitir que el objetivo caiga en todo el tamaño del cliente

¡No puedo creerlo! Muchas gracias, me he estado golpeando la cabeza por esto ( mi pregunta de stackoverflow )

Todos 7 comentarios

@JobaDiniz Si un ItemsControl está vacío, no se mostrará DropTargetInsertionAdorner.

Pero no está vacío, aquí está la muestra .

@JobaDiniz : -DI debería usar un valor predeterminado para esto para evitar tales problemas ...

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

@JobaDiniz Y debe darle a su plantilla personalizada un fondo para permitir que el objetivo caiga en todo el tamaño del cliente

<ControlTemplate>
    <Grid Background="{TemplateBinding Background}">
        <TextBlock Text="Drag items from left ListBox" VerticalAlignment="Center" HorizontalAlignment="Center"/>
    </Grid>
</ControlTemplate>

¿Hay algún truco aquí?

Así que hay una trampa: D Gracias, ¡funcionó!

Y debe darle un fondo a su plantilla personalizada para permitir que el objetivo caiga en todo el tamaño del cliente

¡No puedo creerlo! Muchas gracias, me he estado golpeando la cabeza por esto ( mi pregunta de stackoverflow )

@JobaDiniz Acaba de responder ;-)

Agregaré una nueva propiedad adjunta para permitir mostrar el adorno de destino en ItemsControls vacíos.

ShowDropAdornerOnEmptyTarget

o hay un nombre mejor?

Agregaré una nueva propiedad adjunta para permitir mostrar el adorno de destino en ItemsControls vacíos

No sé si esto es realmente necesario. Mi problema era otra cosa.

¿Fue útil esta página
0 / 5 - 0 calificaciones