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

Using a StackPanel doesn't work (Touch and Mouse) #439

Open
hmuhdkamran opened this issue Mar 25, 2022 · 1 comment
Open

Using a StackPanel doesn't work (Touch and Mouse) #439

hmuhdkamran opened this issue Mar 25, 2022 · 1 comment
Labels

Comments

@hmuhdkamran
Copy link

hmuhdkamran commented Mar 25, 2022

I have a piece of code below, trying to add drag and drop functionality in stack panel

<StackPanel
        AllowDrop="True"
        Orientation="Horizontal"
        VerticalAlignment="Stretch"
        dd:DragDrop.CanDragWithMouseRightButton="True"
        dd:DragDrop.DropTargetAdornerBrush="Coral"
        dd:DragDrop.IsDragSource="True"
        dd:DragDrop.IsDropTarget="True"
        dd:DragDrop.UseDefaultEffectDataTemplate="True">
        <Border Background="Red" Width="140" />
        <Border Background="Green" Width="140" />
        <Border Background="Orange" Width="140" />
        <Border Background="Blue" Width="140" />
        <Border Background="Black" Width="140" />
</StackPanel>

But I didn't succeed

@punker76 punker76 changed the title Using with StackPnel (Touch and Mouse) Using a StackPanel doesn't work (Touch and Mouse) Aug 30, 2022
@punker76
Copy link
Owner

punker76 commented Sep 7, 2022

@hmuhdkamran If you want to use a Control different to an ItemsControl then it's currently not fully supported. Instead you can use an ItemsControl with a horizontal StackPanel inside.

<ItemsControl
    VerticalAlignment="Stretch"
    dd:DragDrop.CanDragWithMouseRightButton="True"
    dd:DragDrop.DropTargetAdornerBrush="Coral"
    dd:DragDrop.IsDragSource="True"
    dd:DragDrop.IsDropTarget="True"
    dd:DragDrop.UseDefaultEffectDataTemplate="True">

    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation="Horizontal" IsItemsHost="True" />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>

    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Border Background="{Binding}" Width="140" />
        </DataTemplate>
    </ItemsControl.ItemTemplate>

    <SolidColorBrush Color="Red" />
    <SolidColorBrush Color="Green" />
    <SolidColorBrush Color="Orange" />
    <SolidColorBrush Color="Blue" />
    <SolidColorBrush Color="Black" />
</ItemsControl>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants