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

Keep dragged/dropped item in listbox selected

3 Answers 75 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Jeroen
Top achievements
Rank 1
Jeroen asked on 26 Jun 2013, 03:32 PM
Hi,

I'm trying to figure out which event is fired when you drag and drop an item within the same listbox?

The actual problem I have is that when I drop my item in the same listbox (I only want to support reordering items in the listbox), the selected item automatically becomes unselected. I want the item that I just dropped to STAY selected. I can't find any property that causes that behaviour, and I can't find any event in which I can handle this myself.

I've tried DragDropManager.AddDragDropCompletedHandler(), DragDropManager.AddDropHandler(), the Drop event... Nothing seems to work.

How should I approach this?

Kind regards,
-- Jeroen

3 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 27 Jun 2013, 02:01 PM
Hi Jeron,

Usually this would be done in the Drop handler. However, if you are using the ListBoxDragDropBehavior, you have to subscribe to the drop event with handledEventsToo set to true.

Let me know if that helps! 

Regards,
Nik
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Jeroen
Top achievements
Rank 1
answered on 28 Jun 2013, 10:03 AM
How do I do that? I'm guessing using AddHandler in code behind, but I can't seem to figure out how to subscribe a DropEvent that way. I'm working in C#.

My listbox is defined as follows:

<telerik:RadListBox ItemsSource="{Binding BitmapComponentModel.ListLayers}" x:Name="LbLayers" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                                    ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Margin="2"
                                    Style="{StaticResource RadListBoxStyle}"
                                    SelectedItem="{Binding BitmapComponentModel.SelectedLayer, Mode=TwoWay}" SelectionChanged="LbLayers_SelectionChanged"
                                    SelectionMode="Single"
                                    Background="Black">
                    <telerik:RadListBox.DragVisualProvider>
                        <telerik:ScreenshotDragVisualProvider />
                    </telerik:RadListBox.DragVisualProvider>
                    <telerik:RadListBox.DragDropBehavior>
                        <telerik:ListBoxDragDropBehavior AllowReorder="True"/>
                    </telerik:RadListBox.DragDropBehavior>
                    <telerik:RadListBox.ItemTemplate>
                        <DataTemplate>
                            <!-- ... -->
                        </DataTemplate>
                    </telerik:RadListBox.ItemTemplate>
                </telerik:RadListBox>
0
Jeroen
Top achievements
Rank 1
answered on 02 Jul 2013, 03:23 PM
I figured it out...

DragDropManager.AddDropHandler(LbLayers, OnElementDrop, true);

That seems to work. Thanks!
Tags
DragAndDrop
Asked by
Jeroen
Top achievements
Rank 1
Answers by
Nick
Telerik team
Jeroen
Top achievements
Rank 1
Share this question
or