This question is locked. New answers and comments are not allowed.
Hi the Telerik Team !
I'm having a strange behavior happening when I use the Drag and drop properties on items contained in a trewview.
My point is to be able to drag and drop a treeview item (that is contained for example in a folder) into another folder of the treeview.
Normally simple
But when I do this, the silverlight project freezes totally, and if I close then open my widget again, it comes back still frozen, and I can't do anything else than rebooting the application.
I can't see what's freezing the application like this. If youcan give me a clue or a solution, please.
Here is my code.
Thanks in advance for the help :)
I'm having a strange behavior happening when I use the Drag and drop properties on items contained in a trewview.
My point is to be able to drag and drop a treeview item (that is contained for example in a folder) into another folder of the treeview.
Normally simple
But when I do this, the silverlight project freezes totally, and if I close then open my widget again, it comes back still frozen, and I can't do anything else than rebooting the application.
I can't see what's freezing the application like this. If youcan give me a clue or a solution, please.
Here is my code.
Thanks in advance for the help :)
*---------------ConfigurationDragBehavior.cs-------------* using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using StormUI.Extensions.Inline; using StormUI.Telerik.Extensions.DragAndDrop; using Dashboard.Modules.Common.Objects; using System.Collections.ObjectModel; namespace ElementInformation.DragAndDropBehavior { public class ConfigurationDragBehavior : InlineAction, ITelerikDragAndDropBehavior { bool IsAttached = false; ObservableCollection<LayoutField> Fields; protected override void Invoke(System.Collections.Generic.List<object> Parameters) { if (Parameters.Count > 0 && Parameters[0] is ObservableCollection<LayoutField>) Fields = Parameters[0] as ObservableCollection<LayoutField>; } void Attach(FrameworkElement element) { if (IsAttached == true) return; IsAttached = true; MBinding.FillBindings(Bindings); MBinding.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(MBinding_PropertyChanged); MBinding.BindedElement = element; MBinding.Update(); } #region ITelerikDragAndDropBehavior Members public bool DragInfo(object sender, Telerik.Windows.Controls.DragDrop.DragDropEventArgs e) { Attach(sender as FrameworkElement); return true; } public void DragQuery(object sender, Telerik.Windows.Controls.DragDrop.DragDropQueryEventArgs e) { Attach(sender as FrameworkElement); e.QueryResult = true; } public bool DropInfo(object sender, Telerik.Windows.Controls.DragDrop.DragDropEventArgs e) { Attach(sender as FrameworkElement); if (e.Options.Source.DataContext is LayoutField && e.Options.Destination.DataContext is LayoutField && Fields.Contains(e.Options.Destination.DataContext as LayoutField)) { if (e.Options.Status != Telerik.Windows.Controls.DragDrop.DragStatus.DropComplete) return true; int index = Fields.IndexOf(e.Options.Destination.DataContext as LayoutField); Fields.Remove(e.Options.Source.DataContext as LayoutField); Fields.Insert(index, e.Options.Source.DataContext as LayoutField); } return false; } public void DropQuery(object sender, Telerik.Windows.Controls.DragDrop.DragDropQueryEventArgs e) { Attach(sender as FrameworkElement); if (e.Options.Destination.DataContext is LayoutField && Fields.Contains(e.Options.Destination.DataContext as LayoutField)) e.QueryResult = true; } #endregion } } *-----------------ConfigurationDropInfo.cs --------------* using System; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Telerik.Windows.Controls.DragDrop; using StormUI.Telerik.Extensions.DragAndDrop; using System.Reflection; using Hypercast.Proxy.Dashboard.Entities; using Telerik.Windows.Controls.TreeView; using StormUI.Extensions.Inline; using System.Collections.Generic; using Dashboard.Modules.Common.Objects; using System.Collections.ObjectModel; namespace ElementInformation.DragAndDropBehavior { public class ConfigurationDropInfo : ITelerikDragAndDropBehavior { #region ITelerikDragAndDropBehavior Members public bool DragInfo(object sender, DragDropEventArgs e) { return true; } public void DragQuery(object sender, DragDropQueryEventArgs e) { e.QueryResult = true; } public bool DropInfo(object sender, DragDropEventArgs e) { TreeViewDragCue dragcue = e.Options.DragCue as TreeViewDragCue; if (e.Options.Source.DataContext is Type) RadDragAndDropManager.CancelDrag(); if (e.Options.Source.DataContext is PropertyInfo) { PropertyInfo property = e.Options.Source.DataContext as PropertyInfo; if (e.Options.Destination.Tag as string == "SEARCH") { bool IsSearchable = (bool)TypeGenerator.GetAttributeValue(property, TypeGenerator.SearchableAttribute).FirstOrDefault(); if (dragcue != null) dragcue.IsDropPossible = IsSearchable; return IsSearchable; } if (e.Options.Destination.Tag as string == "RESULT") { bool IsVisible = (bool)TypeGenerator.GetAttributeValue(property, TypeGenerator.VisibleAttribute).FirstOrDefault(); if (dragcue != null) dragcue.IsDropPossible = IsVisible; return IsVisible; } if (dragcue != null) dragcue.IsDropPossible = true; return true; } if (dragcue != null) dragcue.IsDropPossible = false; return false; } public void DropQuery(object sender, DragDropQueryEventArgs e) { TreeViewDragCue cue = e.Options.DragCue as TreeViewDragCue; if (e.Options.Status == DragStatus.DropDestinationQuery) cue.IsDropPossible = true; else cue.IsDropPossible = false; e.QueryResult = true; } #endregion } } *------------------------ListBoxDragBehavior.cs -********************** using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using StormUI.Telerik.Extensions.DragAndDrop; using Telerik.Windows.Controls.DragDrop; using System.Collections; using System.Windows.Threading; using System.Reflection; namespace ElementInformation.DragAndDropBehavior { public class ListBoxDragBehavior : ITelerikDragAndDropBehavior { DispatcherTimer _Timer; public ListBoxDragBehavior() { _Timer = new DispatcherTimer(); _Timer.Interval = new TimeSpan(0, 0, 0, 0, 1); _Timer.Tick += new EventHandler(_Timer_Tick); } void _Timer_Tick(object sender, EventArgs e) { _Timer.Stop(); RadDragAndDropManager.CancelDrag(); } #region ITelerikDragAndDropBehavior Members public bool DragInfo(object sender, Telerik.Windows.Controls.DragDrop.DragDropEventArgs e) { if (e.Options.Status != DragStatus.DragCancel && (e.Options.Source.DataContext == null || e.Options.Source.DataContext is Type || (e.Options.Source.DataContext is PropertyInfo && typeof(IList).IsAssignableFrom((e.Options.Source.DataContext as PropertyInfo).PropertyType)))) { _Timer.Start(); } return true; } public void DragQuery(object sender, Telerik.Windows.Controls.DragDrop.DragDropQueryEventArgs e) { } public bool DropInfo(object sender, Telerik.Windows.Controls.DragDrop.DragDropEventArgs e) { return true; } public void DropQuery(object sender, Telerik.Windows.Controls.DragDrop.DragDropQueryEventArgs e) { } #endregion } }