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

Drag/Drop exception

1 Answer 53 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Tal
Top achievements
Rank 1
Tal asked on 25 Jan 2009, 04:12 PM
Hi,
I've created a simple solution to test the RadTreeview.It just initializes a new ObservableCollection of Items like this:
 /// <summary> 
    /// Interaction logic for Window1.xaml 
    /// </summary> 
    public partial class Window1 : Window 
    { 
        public ObservableCollection<Item> Items 
        { 
            get { return (ObservableCollection<Item>)GetValue(ItemsProperty); } 
            set { SetValue(ItemsProperty, value); } 
        } 
 
        // Using a DependencyProperty as the backing store for Items.  This enables animation, styling, binding, etc... 
        public static readonly DependencyProperty ItemsProperty = 
            DependencyProperty.Register("Items"typeof(ObservableCollection<Item>), typeof(Window1)); 
 
        public Window1() 
        { 
            InitializeComponent(); 
            Items = new ObservableCollection<Item>(); 
 
            Items.Add(new Item("Item 1")); 
            Items.Add(new Item("Item 2")); 
            Items.Add(new Item("Item 3")); 
        } 
    } 
 
    public class Item 
    { 
        public string Header { getset; } 
        public ObservableCollection<Item> Items { getset; } 
 
        public Item(string header) 
        { 
            Header = header; 
            Items = new ObservableCollection<Item>(); 
        } 
    } 

and in xaml created a simple HierarchicalDataTemplate:
<Window.Resources> 
        <HierarchicalDataTemplate x:Key="NodeTemplate" ItemsSource="{Binding Path=Items}"
            <StackPanel Orientation="Horizontal"
                <TextBlock Text="{Binding Path=Header}"/> 
            </StackPanel> 
        </HierarchicalDataTemplate> 
    </Window.Resources> 
    <Grid> 
        <Telerik:RadTreeView IsDragDropEnabled="True" Name="t"  
                             ItemsSource="{Binding Path=Items, ElementName=window}"  
                             ItemTemplate="{StaticResource NodeTemplate}"
        </Telerik:RadTreeView> 
    </Grid> 

Now, when I am trying to drag "Item 1" to, lets say, "Item 2" it works ok. But if afterwards I am trying to drag "Item 3" to "Item 1" (that is now under "Item 2") I am getting a NullReferenceException with the following stack trace:
   at Telerik.Windows.Controls.RadTreeViewItem.CheckStatePropertyChangedConstrainValue(DependencyObject d, Object newValue) 
   at System.Windows.DependencyObject.ProcessCoerceValue(DependencyProperty dp, PropertyMetadata metadata, EntryIndex& entryIndex, Int32& targetIndex, EffectiveValueEntry& newEntry, EffectiveValueEntry& oldEntry, Object& oldValue, Object baseValue, CoerceValueCallback coerceValueCallback, Boolean coerceWithDeferredReference, Boolean skipBaseValueChecks) 
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, OperationType operationType) 
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, OperationType operationType, Boolean isInternal) 
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value) 
   at Telerik.Windows.Controls.RadTreeViewItem.set_CheckState(ToggleState value) 
   at Telerik.Windows.Controls.RadTreeViewItem.SetCheckStateWithNoPropagation(ToggleState state) 
   at Telerik.Windows.Controls.RadTreeViewItem.Render(Boolean recursive) 
   at Telerik.Windows.Controls.RadTreeViewItem.OnItemsChanged(NotifyCollectionChangedEventArgs e) 
   at System.Windows.Controls.ItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e) 
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e) 
   at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args) 
   at System.Windows.Controls.ItemCollection.System.Windows.IWeakEventListener.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e) 
   at System.Windows.WeakEventManager.DeliverEventToList(Object sender, EventArgs args, ListenerList list) 
   at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args) 
   at System.Collections.Specialized.CollectionChangedEventManager.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args) 
   at System.Windows.Data.CollectionView.OnCollectionChanged(NotifyCollectionChangedEventArgs args) 
   at System.Windows.Data.ListCollectionView.ProcessCollectionChangedWithAdjustedIndex(NotifyCollectionChangedEventArgs args, Int32 adjustedOldIndex, Int32 adjustedNewIndex) 
   at System.Windows.Data.ListCollectionView.ProcessCollectionChanged(NotifyCollectionChangedEventArgs args) 
   at System.Windows.Data.CollectionView.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs args) 
   at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e) 
   at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item) 
   at System.Collections.ObjectModel.Collection`1.Add(T item) 
   at System.Collections.ObjectModel.Collection`1.System.Collections.IList.Add(Object value) 
   at Telerik.Windows.Controls.RadTreeView.EndDrag() 
   at Telerik.Windows.Controls.RadTreeView.HandleMouseUp(MouseEventArgs e) 
   at Telerik.Windows.Controls.RadTreeView.RadTreeView_MouseLeftButtonUp(Object sender, MouseEventArgs e) 
   at System.Windows.Input.MouseButtonEventArgs.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.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent) 
   at System.Windows.UIElement.CrackMouseButtonEventAndReRaiseEvent(DependencyObject sender, MouseButtonEventArgs e) 
   at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e) 
   at System.Windows.Input.MouseButtonEventArgs.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.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, Int32 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, Boolean isSingleParameter) 
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) 
   at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) 
   at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter) 
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) 
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) 
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) 
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) 
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame) 
   at System.Windows.Threading.Dispatcher.Run() 
   at System.Windows.Application.RunDispatcher(Object ignore) 
   at System.Windows.Application.RunInternal(Window window) 
   at System.Windows.Application.Run(Window window) 
   at System.Windows.Application.Run() 
   at Telerik.App.Main() in C:\Documents and Settings\talg\Desktop\TreeViewDrag\Telerik\Telerik\obj\Debug\App.g.cs:line 0 
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) 
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
   at System.Threading.ThreadHelper.ThreadStart() 

To make things even worse, it's not constant. It happens in about 50% of the tries.
Thank you in advance,
Tal

1 Answer, 1 is accepted

Sort by
0
Ivan
Telerik team
answered on 29 Jan 2009, 02:53 PM
Hi Tal,

Thank you for reporting this issue.

This seems to be a bug in our control and we will be looking into resolving it with the forthcoming releases.

Your Telerik points have been updated for your report.

Sincerely yours,
Ivan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Tal
Top achievements
Rank 1
Answers by
Ivan
Telerik team
Share this question
or