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

Remove DropVisual

1 Answer 22 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Kieron
Top achievements
Rank 1
Kieron asked on 05 May 2016, 11:02 AM

I have a listbox which the user can drag from and drop on a scheduleview.. however I've restricted the user so that they can't drop back onto the listbox and therefore they also can't re-order the listbox.

To get this working was simple enough - however I had a bit of difficulty getting rid of the DropVisual that happens when you hover on the listbox with an item you are dragging.  (The visual I am talking about is the bar that appears above/below each listboxitem to indicate where it is going to drop - I want to get rid of this because the user can't drop here - I'm surprised its not supressed when AllowDrop is set to False).

I tried setting the DropVisualProvider to null on the Listbox itself - this in turn caused loads of silent NullReferenceExceptions and caused flickering when holding an item over the ListBox.  I then set the DropVisualProvider to a class which inherited from LinearDropVisualProvider and overrode the CreateDropVisual method to just return a blank StackPanel - this works flawlessly, but is there an easier/less hacky way of achieving this?

1 Answer, 1 is accepted

Sort by
0
Masha
Telerik team
answered on 09 May 2016, 08:04 AM
Hello Kieron,

In order to achieve the desired approach I suggest you overwrite LinerDropVisuslStyle as follow:

<telerik:RadListBox Height="300" Width="200" ItemsSource="{Binding Cars}">
       <telerik:RadListBox.Resources>
             <Style TargetType="telerik:LinearDropVisual"  />
        </telerik:RadListBox.Resources>
</telerik:RadListBox>

I hope this would be helpful.

Regards,
Masha
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
ListBox
Asked by
Kieron
Top achievements
Rank 1
Answers by
Masha
Telerik team
Share this question
or