Remove DropVisual

2 posts, 0 answers
  1. Kieron
    Kieron avatar
    16 posts
    Member since:
    Nov 2013

    Posted 05 May Link to this post

    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?

  2. Masha
    Masha avatar
    355 posts

    Posted 09 May Link to this post

    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}">
                 <Style TargetType="telerik:LinearDropVisual"  />

    I hope this would be helpful.

    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top