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

Drag from a read-only items source (without removing items)

2 Answers 186 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Valeriu
Top achievements
Rank 1
Valeriu asked on 20 Aug 2012, 08:26 AM

I'm trying to accomplish a scenario and I'm failing to find a decent info about your drag and drop implementation. Help is seriously lacking info and have mixed RadDragAndDropManager and DragDropManager content which doesn't helps at all.

My scenario:

 - Read only list (displayed in a RadListBox)

 - Another RadListBox that should be populated with items from first one

 - A Converter that converts items from one format to another

So I would like that items from first list aren't removed. In my current implementation I'm receiving an exception when dropping items on second list telling me that ItemsSource from the read-only listbox cannot be modified.

Any hints on how to accomplish this simple requirement?

Thanks

Exception details:

System.InvalidOperationException was unhandled by user code
  HResult=-2146233079
  Message=Operation is not valid while ItemsSource is in use. Access and modify elements with ItemsControl.ItemsSource instead.
  Source=PresentationFramework
  StackTrace:
       at System.Windows.Controls.ItemCollection.CheckIsUsingInnerView()
       at System.Windows.Controls.ItemCollection.Remove(Object removeItem)
       at Telerik.Windows.DragDrop.Behaviors.DragDropBehavior`1.RemoveItems(IList source, IEnumerable items) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\Behaviors\Common\DragDropBehavior.cs:line 186
       at Telerik.Windows.DragDrop.Behaviors.DragDropBehavior`1.DragDropCompleted(TState state) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\Behaviors\Common\DragDropBehavior.cs:line 161
       at Telerik.Windows.DragDrop.Behaviors.DragDropHelper`2.DragDropCompleted(FrameworkElement dropItemsControl, Object data, Type itemType, Boolean wasCanceled) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\Behaviors\Common\DragDropHelper.cs:line 228
       at Telerik.Windows.DragDrop.Behaviors.DragDropHelper`2.CompleteDrag(Object data, DragDropEffects effects) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\Behaviors\Common\DragDropHelper.cs:line 398
       at Telerik.Windows.DragDrop.Behaviors.DragDropHelper`2.DragDropCompleted(Object sender, DragDropCompletedEventArgs e) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\Behaviors\Common\DragDropHelper.cs:line 392
       at Telerik.Windows.DragDrop.DragDropCompletedEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\DragDropCompletedEventArgs.cs:line 61
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
       at Telerik.Windows.DragDrop.IInputElementExtensions.RaiseEvent(DependencyObject d, RoutedEventArgs routedEventArgs) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\DependencyObjectExtensions.cs:line 82
       at Telerik.Windows.DragDrop.DragDropManager.DoDragDrop(DependencyObject dragSource, Object data, DragDropEffects allowedEffects, DragDropKeyStates initialKeyState, Object dragVisual, Point relativeStartPoint, Point dragVisualOffset) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\DragDropManager.cs:line 1026
       at Telerik.Windows.DragDrop.DragInitializer.StartDrag() in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\DragInitializer.cs:line 236
       at Telerik.Windows.DragDrop.DragInitializer.StartDragPrivate(UIElement sender) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\DragInitializer.cs:line 186
       at Telerik.Windows.DragDrop.DragInitializer.DragSourceOnMouseMove(Object sender, MouseEventArgs e) in c:\TB\117\WPF_Scrum\Release_WPF\Sources\Development\Core\Controls\DragDropManager\DragInitializer.cs:line 163
       at System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
       at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
       at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
       at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
       at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
       at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
       at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
       at System.Windows.Input.InputManager.ProcessStagingArea()
       at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
       at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
       at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
       at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
  InnerException: 

2 Answers, 1 is accepted

Sort by
0
Valeriu
Top achievements
Rank 1
answered on 20 Aug 2012, 09:29 AM
Overriding the DragDropManager.DragDropCompleted allowed me to implement my scenario.
0
Dimitrina
Telerik team
answered on 20 Aug 2012, 09:57 AM
Hi,

 Thank you for the update. I will as well suggest you to check our Drag and Drop Demos showing working examples on how to benefit from DragDropManager.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
DragAndDrop
Asked by
Valeriu
Top achievements
Rank 1
Answers by
Valeriu
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or