This is a migrated thread and some comments may be shown as answers.

Drag Drop Between ListBox and Caliburn Micro

0 Answers 169 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Dickson
Top achievements
Rank 1
Dickson asked on 31 Jan 2013, 12:19 AM
Hi,

I am currently using Silverlight 4, Caliburn Micro and the RadDragAndDropManager to implement a drag and drop of listboxitems between two listboxes.

There isn't much examples done with Caliburn Micro. I am hoping someone can provide a simple example done with Caliburn Micro.

I am not too sure if I am going in the right direction because I AM able to trigger the DragQuery event when dragging an item in the source listbox. However, there is no DragCue visible at all. Also, when releasing the mouse in the target listbox, I am not able to trigger the Drop related events.

The following is the XAML for the one of the listboxes I wrote. The other one is exactly the same with the same triggers.

<ListBox Grid.Row="2"
                 ItemsSource="{Binding Items}"
                 telerik:RadDragAndDropManager.AllowDrag="True"
                 telerik:RadDragAndDropManager.AllowDrop="True">
            <i:Interaction.Triggers>
                <trigger:DragQueryRoutedEventTrigger EventName="DragQuery">
                    <cal:ActionMessage MethodName="DragQuery">
                        <cal:Parameter Value="$source" />
                        <cal:Parameter Value="$eventArgs" />
                        <cal:Parameter Value="$view" />
                    </cal:ActionMessage>
                </trigger:DragQueryRoutedEventTrigger>
                <trigger:DropQueryRoutedEventTrigger EventName="DropQuery">
                    <cal:ActionMessage MethodName="DropQuery">
                        <cal:Parameter Value="$source" />
                        <cal:Parameter Value="$eventArgs" />
                        <cal:Parameter Value="$view" />
                    </cal:ActionMessage>
                </trigger:DropQueryRoutedEventTrigger>
            </i:Interaction.Triggers>
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="telerik:RadDragAndDropManager.AllowDrag" Value="True" />
                    <Setter Property="telerik:RadDragAndDropManager.AllowDrop" Value="True" />
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>

I have the following methods in my View Model. I cannot get any DragCues going and cannot trigger the DropQuery method.
public void DragQuery(object sender, DragDropQueryEventArgs e, RulesManagerView view)
        {
            if (e.Options.Status == DragStatus.DragQuery)
            {
                var draggedItem = e.Options.Source;
                // Create Drag Cue
                // 1. Create a ContentControl. It will be used as a DragCue.
                ContentControl dragCue = new ContentControl();
                // 2. Set the dragged item to the ContentControl's Content property.
                dragCue.Content = draggedItem.DataContext;
                // 3. Use a DataTemplate to "say" how the dragged item will be displayed.
                dragCue.ContentTemplate = view.Resources["DragCueTemplate"] as DataTemplate;
                // 4. Set the ContentControl to the DragDropOptions' DragCue property.
                e.Options.DragCue = dragCue;
 
                // The other code follow here
            }
        }
 
        public void DropQuery(object sender, DragDropQueryEventArgs e, RulesManagerView view)
        {
             
        }

No answers yet. Maybe you can help?

Tags
DragAndDrop
Asked by
Dickson
Top achievements
Rank 1
Share this question
or