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

[Solved] Compatibility broken on Q2 release

8 Answers 143 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ivo
Top achievements
Rank 1
Ivo asked on 15 Jul 2009, 05:07 PM
Hi,

I recently updated to Q2 release and now the tree does not automaticaly reorder the childs of an root
Imagine this situation:
A
--B
--C
--D

    <telerikNavigation:RadTreeView Margin="30" x:Name="radTree" IsEditable="true" IsDragDropEnabled="True" IsLineEnabled="True">
            <telerikNavigation:RadTreeViewItem Header="A" x:Name="typea" IsDropAllowed="True" IsExpanded="True">
                <telerikNavigation:RadTreeViewItem Header="B" IsDropAllowed="False"/>
                <telerikNavigation:RadTreeViewItem Header="C" IsDropAllowed="False"/>
                <telerikNavigation:RadTreeViewItem Header="D" IsDropAllowed="False"/>
            </telerikNavigation:RadTreeViewItem>
        </telerikNavigation:RadTreeView>

After the Q2 release I could without any code change the order of the childs like for example this:
A
--C
--B
--D
Simply by dragging C before B, but now in Q2 I do that same action and the tree stays exactly the same.

Has something changed?How can I have this beahviour once again?

8 Answers, 1 is accepted

Sort by
0
Ivo
Top achievements
Rank 1
answered on 15 Jul 2009, 05:19 PM
I did some experiments and this appears to work if I change IsDropAllowed="True" in all child nodes...which is strange because in Q1I could have this property set to false...can anybody enlight me on this?
  
0
Ivo
Top achievements
Rank 1
answered on 15 Jul 2009, 06:51 PM
I have on more issue, to stop the childs from being added before or after the root I have the following code

XAML:
 <Grid x:Name="LayoutRoot" Background="White">
        <telerikNavigation:RadTreeView Margin="30" x:Name="radTree" IsEditable="true" IsDragDropEnabled="True" IsLineEnabled="True">
            <telerikNavigation:RadTreeViewItem Header="A" x:Name="typea" IsDropAllowed="True" IsExpanded="True">
                <telerikNavigation:RadTreeViewItem Header="B" IsDropAllowed="True"/>
                <telerikNavigation:RadTreeViewItem Header="C" IsDropAllowed="True"/>
                <telerikNavigation:RadTreeViewItem Header="D" IsDropAllowed="True"/>
            </telerikNavigation:RadTreeViewItem>
        </telerikNavigation:RadTreeView>
    </Grid>



Code Behind:
public Page()
        {
            InitializeComponent();

            this.radTree.PreviewDragEnded += new RadTreeViewDragEndedEventHandler(radTree_PreviewDragEnded);
        }

        void radTree_PreviewDragEnded(object sender, RadTreeViewDragEndedEventArgs e)
        {
            if ((e.DropPosition == DropPosition.After || e.DropPosition == DropPosition.Before)&& e.TargetDropItem == typea)
            {
                e.Handled = true;
            }

        }

So this kinda works but I don't khow what happens but the child node being dragged simply disapears it doesn't get added before or after the root, the node simply disapears!
It appears to me that the behaviour of drag and drop on treeview has been completly changed which is understandable, but some backwards compatibility would have been nice :(

0
Miroslav
Telerik team
answered on 16 Jul 2009, 10:46 AM
Hi Ivo,

The TreeView DragDrop was changed for this release and now allows dragging across controls.

We did not intend to introduce any breaking changes and what you are seeing is a bug. We expect to fix it so that it works as before for tomorrow's internal build. The fix will also be included in the coming SP.

I am sorry for breaking your existing code, we will make sure it works as expected.

Best wishes,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ivo
Top achievements
Rank 1
answered on 21 Jul 2009, 10:51 AM
Thanks Miroslav for the reply,

The fix did solve my problems, but now I have another.
Now the cue that represents the object being drag simply appears as an empty square, without the text or the icon.
Is it possible to set it manualy I already tried but with no sucess...
Can you help me on this?

Thanks,
Ivo

0
Miroslav
Telerik team
answered on 21 Jul 2009, 01:10 PM
Hello Ivo,

The TreeView DragDrop is under development now and not everything may work. Still, I did not expect  this kind of change will be present.

Could you give more details on when this happens. Are you handling / cancelling an event? I am sending a simple application where I tried to go through some of the scenarios for the DragDrop but did not see this.

I have updated your Telerik points for your feedback.

Kind regards,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ivo
Top achievements
Rank 1
answered on 21 Jul 2009, 03:40 PM
Hi Miroslav,

You were right it behaves correctly, the previous problem was due to an theme that I was using, so I removed the theme but then another problem happened out of nowhere while I were dragging the Item this exception happens:

Value does not fall within the expected range.
at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
   at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper obj, DependencyProperty property, DependencyObject doh)
   at MS.Internal.XcpImports.SetValue(INativeCoreTypeWrapper doh, DependencyProperty property, Object obj)
   at System.Windows.DependencyObject.SetObjectValueToCore(DependencyProperty dp, Object value)
   at System.Windows.DependencyObject.RefreshExpression(DependencyProperty dp)
   at System.Windows.TemplateBindingExpression.SourcePropertyChanged(DependencyObject c, DependencyProperty dp)
   at System.Windows.DependencyPropertyChangedWeakListener.SourcePropertyChanged(DependencyObject c, DependencyProperty dp)
   at System.Windows.DPChangedEventHandler.Invoke(DependencyObject sender, DependencyProperty dp)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyProperty dp)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyProperty dp)
   at System.Windows.DependencyObject.RaisePropertyChangeNotifications(DependencyProperty dp, Object newValue, Object oldValue)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value, Boolean allowReadOnlySet, Boolean isSetByStyle, Boolean isSetByBuiltInStyle, PropertyInvalidationReason reason)
   at System.Windows.DependencyObject.SetValueInternal(DependencyProperty dp, Object value)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Telerik.Windows.Controls.TreeView.TreeViewDragCue.set_DragTooltipContent(Object value)
   at Telerik.Windows.Controls.RadTreeView.OnTreeViewDropInfo(Object sender, DragDropEventArgs e)

After almost 7 hours I manage to find what is causing this problem.
My RadTreeViewItems are dynamicaly created and added to the tree.This items are an UserControl that I assign to the header of the RadTreeViewItem.This UserControl implements the ToString() method which is used by the default drag and drop text of the tree.
In this scenario when I tried to drag and drop I get the above error, when I assign to the header of the RadTreeViewItem something like a string the error doesen't happen.
I created a small example reproducing this error, I don't khow If I can send to you so i'm posting in this thread the source code:
Main page.xaml:
´
<UserControl x:Class="RadTreeviewExample_SL.Page" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
    Width="400" Height="300"> 
     
    <Grid x:Name="LayoutRoot" Background="White"> 
        <telerikNavigation:RadTreeView Margin="30" x:Name="radTree" IsEditable="true" IsDragDropEnabled="True" IsLineEnabled="True"> 
            <telerikNavigation:RadTreeViewItem Header="A" x:Name="typea" IsDropAllowed="True" IsExpanded="True"> 
                 
            </telerikNavigation:RadTreeViewItem> 
        </telerikNavigation:RadTreeView> 
    </Grid> 
</UserControl> 
 
Main page.cs: 
public partial class Page : UserControl 
    { 
        public Page() 
        { 
            InitializeComponent(); 
         
            RadTreeViewItem newnewItem = new RadTreeViewItem(); 
            FlowChildTree fct = new FlowChildTree(); 
            fct.ChildName = "C"; 
 
            RadTreeViewItem newnewItems = new RadTreeViewItem();           
            FlowChildTree fcts = new FlowChildTree(); 
            fcts.ChildName = "D"; 
 
 
            RadTreeViewItem parent = ((RadTreeViewItem)radTree.Items[0]);             
            newItem.Header = fct; 
            newItems.Header = fcts; 
            parent.Items.Insert(0, newItem); 
            parent.Items.Insert(1, newItems);           
 
        } 
    } 


User control for the RadTreeViewItem xaml:
<UserControl x:Class="RadTreeviewExample_SL.FlowChildTree" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"      
    
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:l="clr-namespace:RadTreeviewExample_SL;assembly=RadTreeviewExample_SL" 
 
    xmlns:telerikPrim="clr-namespace:Telerik.Windows.Controls.Primitives;assembly=Telerik.Windows.Controls" 
    xmlns:telerikCtrl="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
    xmlns:telerikNav="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
 
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"> 
    <UserControl.Resources> 
        
 
    </UserControl.Resources> 
 
    <Grid x:Name="LayoutRoot"> 
        <Grid.ColumnDefinitions> 
            <ColumnDefinition Width="auto"/> 
 
        </Grid.ColumnDefinitions> 
        <Border Grid.Column="1" BorderThickness="1" BorderBrush="Black"> 
            <Grid> 
                <Grid.ColumnDefinitions> 
                    <ColumnDefinition Width="auto"/> 
         
                </Grid.ColumnDefinitions> 
                 
                <StackPanel Grid.Column="0" VerticalAlignment="Center" Orientation="Vertical"> 
                    <TextBlock x:Name="childName"  Margin="0,0,5,0" FontSize="12" TextAlignment="Right"></TextBlock> 
                </StackPanel> 
            </Grid> 
        </Border> 
 
    </Grid> 
</UserControl> 


User control for the RadTreeViewItem cs:

public partial class FlowChildTree : UserControl 
    { 
        public static readonly DependencyProperty ChildNameProperty = 
        DependencyProperty.Register("ChildName", typeof(string), typeof(FlowChildTree), new PropertyMetadata(new PropertyChangedCallback(ChildNameValueChanged))); 
  
        public string ChildName 
        { 
            get 
            { 
                return (string)GetValue(ChildNameProperty); 
            } 
            set 
            { 
                SetValue(ChildNameProperty, value); 
            } 
        } 
   
        public FlowChildTree() 
        { 
            InitializeComponent(); 
             
        } 
 
        public override string ToString() 
        { 
            return ChildName; 
        } 
        static void ChildNameValueChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) 
        { 
            FlowChildTree flowChildTree = sender as FlowChildTree; 
            flowChildTree.childName.Text = (string)e.NewValue; 
        } 
    } 
} 


If you try this out i will get the error that I mention earlier.This does not happen on Q1 release and works perfectly.
I would realy appreciate if you can could help me on this Miroslav.
Thanks and regards,
Ivo







0
Miroslav
Telerik team
answered on 22 Jul 2009, 03:15 PM
Hi Ivo,

I am sorry to hear that it has taken you that much time to find that this is causing the issue.

Your Telerik points have been updated for your feedback.

The issue comes from the fact that the DragCue was using the header of the destination template to show where it is going to be dropped while it had to be more clever and try to extract a non-visual representation. (As the DragPreview does). Here is how the what preview does (and how the destination item will be shown):

- If the item is non-dependency object, use it
- Retrieve its TextSearch.Text property if available
- Use its Header if the Header is non-visual
- Use the TextSearch.Text of the Header
- Use the ToString() of the Header.

Unfortunately since we are trying to make the DragCue usable outside the TreeView, the DefaultImageSrc will probably not be visible in the DragCue. We are working on a way to bring it back now.

Do you think that it is important to always show the DefaultImage?

These changes will be available with this week's  Internal build (which hopefully will not come out late as the last one).

Greetings,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ivo
Top achievements
Rank 1
answered on 22 Jul 2009, 04:16 PM
Hi Miroslav,

Thanks for the feedback on this. As soon as the internal build gets release I will update you on this situation.
Regarding the DefaultImageSrc I don't know if you are talking only about the target object representation because I think that it gives a really nice feedback to the user, but if it is not possible to showed at least the drag In, drag before and drag after text(without the target object representation) should appear and the same goes to the object being dragged.

Once again thanks for quick reply,
Ivo
Tags
TreeView
Asked by
Ivo
Top achievements
Rank 1
Answers by
Ivo
Top achievements
Rank 1
Miroslav
Telerik team
Share this question
or