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

Drag & Drop Display Issue With Hierarchical Data Templates

2 Answers 80 Views
This is a migrated thread and some comments may be shown as answers.
Geoff Davis
Top achievements
Rank 1
Geoff Davis asked on 02 Apr 2010, 05:53 PM

I'm working with a two-level treeview and am able to drag elements from the first level without any complications.  When I drag from the second level, however, the dragged item displays using the template for the first level.

These are the two templates being used:
<core:HierarchicalDataTemplate x:Key="SectionsTemplate"
                <Border BorderThickness="1,0,1,0" CornerRadius="4" BorderBrush="Red"  
                        Background="{Binding Index, Converter={StaticResource AlternateBrush}}" 
                    <Grid Margin="2" Loaded="SectionsTemplate_Loaded"
                            <ColumnDefinition Width="5" /> 
                            <ColumnDefinition Width="50" /> 
                            <ColumnDefinition Width="90" /> 
                            <ColumnDefinition Width="108" /> 
                            <ColumnDefinition Width="5" /> 
                            <RowDefinition /> 
                            <RowDefinition Height="2" /> 
                            <RowDefinition /> 
                        <!--1st Column--> 
                        <TextBlock Grid.Column="1" Grid.Row="0" 
                                   Text="{Binding SectionNumber}" /> 
                        <TextBlock Grid.Column="1" Grid.Row="2" 
                                   Text="{Binding Days}" />                                                                        
                        <!--2nd Column--> 
                        <TextBlock Grid.Column="2" Grid.Row="0" 
                                   Text="{Binding CallNumber}" /> 
                        <TextBlock Grid.Column="2" Grid.Row="2" 
                                   Text="{Binding TimeSlot}" /> 
                        <!--3rd Column--> 
                        <TextBlock Grid.Column="3" Grid.Row="0" 
                                   Text="{Binding Instructor}" /> 
                        <TextBlock Grid.Column="3" Grid.Row="2" 
                                   Text="{Binding Location}" /> 
            <core:HierarchicalDataTemplate x:Key="CoursesTemplate" 
                                           ItemsSource="{Binding Sections}" 
                                           ItemTemplate="{StaticResource SectionsTemplate}" 
                <Border CornerRadius="5" BorderBrush="Maroon" BorderThickness="1"  
                        <LinearGradientBrush EndPoint="0.5,1" 
                            <GradientStop Color="#7F420000" 
                         Offset="0.92" /> 
                            <GradientStop Color="White" 
                         Offset="0.007" /> 
                            <GradientStop Color="#FF943D3D" 
                         Offset="0.374" /> 
                            <GradientStop Color="#FEB58787" 
                         Offset="0.678" /> 
                            <GradientStop Color="#FF630000" /> 
                    <Grid Margin="2"  Loaded="CoursesTemplate_Loaded"
                            <LinearGradientBrush EndPoint="0.5,1" 
                                <GradientStop Color="#FF922222" 
                          Offset="1" /> 
                                <GradientStop Color="#FFF1DDDD" /> 
                                <GradientStop Color="#FFB54242" 
                          Offset="0.478" /> 
                                <GradientStop Color="#FBB58787" 
                          Offset="0.418" /> 
                            <ColumnDefinition Width="4" /> 
                            <ColumnDefinition Width="70" />                         
                            <ColumnDefinition Width="30" /> 
                            <ColumnDefinition Width="180" />                             
                        <StackPanel Grid.Column="1" Orientation="Horizontal">                         
                            <TextBlock Foreground="White"  Text="{Binding DiscCode}" /> 
                            <TextBlock Foreground="White"  Text="{Binding Number}" />                         
                        <TextBlock Foreground="White"  Grid.Column="2" Text="{Binding Credits}" /> 
                        <TextBlock Foreground="White"  Grid.Column="3" Text="{Binding Name}" /> 

And this is the treeview definition:
<nav:RadTreeView x:Name="CoursesTree" 
                             ItemsSource="{Binding Courses}" 
                             ItemTemplate="{StaticResource CoursesTemplate}" 

I assume this is not an inherent problem in the control, but don't see what in these declarations would cause the issue.  The version of the control being used is 2009.3.1208.1030

Any light that could be shed on this would be greatly appreciated.


2 Answers, 1 is accepted

Sort by
Tina Stancheva
Telerik team
answered on 07 Apr 2010, 06:55 PM
Hi Geoff Davis,

After examining the code snippet you provided I noticed that you set the ItemTemplate property of the RadTreeView. This is the cause for the behavior you noticed. The DagPreview uses the template set as ItemTemplate when displaying the dragged item. If you want to use different templates for the dragged items depending on their type, it is better to set the ItemTemplateSelector property of the RadTreeView.

I prepared an example for you. Please take a look at it and let me know if it works for you.

Kind regards,
Tina Stancheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Geoff Davis
Top achievements
Rank 1
answered on 08 Apr 2010, 12:18 AM
Awesome - thanks for that.

Asked by
Geoff Davis
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Geoff Davis
Top achievements
Rank 1
Share this question