Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
540
Drag and Drop Listbox help
posted

Hey there, quick question, I want to drag a listbox item fromthe listbox to a grid cell.  The listbox item is a custom textbox control called "cEmployeeItem".  The listbox itemssource is bound to the view model and loaded on a button push.

I can't seem to get the listbox item to drag only, I can only get the entire listbox itself to drag.  Below is my xaml.  I commented out the datatemplate section because nothing was happening (not able to drag at all):

 

 

 

 

 

 

 

 

 

<

 

 

 

ListBox HorizontalAlignment="Stretch" Margin="2" Name="lbxUnassignedEmps" VerticalAlignment="Stretch" ItemsSource="{Binding Path=UnassignedEmps, Mode=TwoWay}" AllowDrop

="True" >

 

 

 

 

<!--<ListBox.ItemTemplate>

<DataTemplate>-->

 

 

 

 

<ig:DragDropManager.DragSource

>

 

 

 

 

<ig:DragSource IsDraggable="True" Drop="DragSource_Drop"/>

 

 

 

 

</ig:DragDropManager.DragSource

>

 

 

 

 

<ig:DragDropManager.DropTarget

>

 

 

 

 

<ig:DropTarget IsDropTarget

="True" />

 

 

 

 

</ig:DragDropManager.DropTarget

>

 

 

 

 

<!--</DataTemplate>

</ListBox.ItemTemplate>-->

 

 

 

 

</ListBox>

 

Parents
No Data
Reply
  • 8831
    posted

    Hello,

    It is important to have set the Background on the element where DragSource is attached, otherwise the mouse events are not fired for that element. Also it seems that your data template has no root element where you have to attach the DragSource.

    Plamen.

Children
No Data