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

RadDragDropManager with hierarchical TreeView not firing DropQueryEvent?

1 Answer 65 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Rodd
Top achievements
Rank 1
Rodd asked on 25 Aug 2011, 09:53 PM
I'm trying to handle the DropQuery event so that I can "disable" dropping Before or After a node ... I only want drop In.

I have this XAML
<telerik:RadTreeView x:Name="UnitTree" Grid.Row="3"
                     ItemsSource="{Binding UnitsList, NotifyOnValidationError=True, Converter={StaticResource UnitCollectionConverter}}"
                     IsExpandOnDblClickEnabled="True"
                     SelectedItem="{Binding SelectedUnit, Mode=TwoWay}"
                     ScrollViewer.VerticalScrollBarVisibility="Auto"
                     BorderBrush="Black" BorderThickness="1" Margin="5"
                     AllowDrop="True"
                     IsDragDropEnabled="True" IsDragPreviewEnabled="True"
                     IsDropPreviewLineEnabled="False">
    <telerik:RadTreeView.ItemTemplate >
        <telerik:HierarchicalDataTemplate ItemsSource="{Binding NotifyOnValidationError=True, Converter={StaticResource UnitCollectionConverter}}">
            <StackPanel Orientation="Vertical" Margin="5">
                <StackPanel Orientation="Horizontal">
                    <TextBlock TextWrapping="Wrap" Text="{Binding Name, NotifyOnValidationError=True}" FontWeight="Bold" VerticalAlignment="Center" Width="185"/>
                    <TextBlock TextWrapping="Wrap" Text="*" FontWeight="Bold" FontSize="18" VerticalAlignment="Center"
                                   Foreground="{Binding HasValidationErrors, Converter={StaticResource EntityErrorsToColorBrush}}"
                                   Visibility="{Binding EntityState, Converter={StaticResource EntityStateToVisibility}}"/>
                </StackPanel>
                <TextBlock Text="{Binding UnitType}" FontStyle="Italic" FontSize="10" Foreground="Gray" FontWeight="Bold" />
            </StackPanel>
        </telerik:HierarchicalDataTemplate>
    </telerik:RadTreeView.ItemTemplate>
     
</telerik:RadTreeView>

and this in my code behind
    public partial class EntityNavigator : UserControl
    {
        public EntityNavigator()
        {
            InitializeComponent();
            UnitTree.AddHandler(RadDragAndDropManager.DropQueryEvent, new EventHandler<DragDropQueryEventArgs>(UnitTree_DropQuery));
        }
 
        private void UnitTree_DropQuery(object sender, DragDropQueryEventArgs e)
        {
            //Enabled following line just to force a crash to see if breakpoint wasn't working for some reason
           //var myitem = UnitTree.Items[253];
            var item = e.Options.Destination as RadTreeViewItem;
            if (item.DropPosition != DropPosition.Inside)
                e.QueryResult = false;
        }
}

I set a breakpoint on my UnitTree_DropQuery event handler and it never gets fired.  I am definitely able to drag and drop items in my tree.  I get the preview for drag before, drag in and drag after.  Any ideas on what I'm doing wrong?

Thanks for your help.

1 Answer, 1 is accepted

Sort by
0
Rodd
Top achievements
Rank 1
answered on 25 Aug 2011, 10:01 PM
Shortly after making this post, I ran across this: http://www.telerik.com/community/forums/silverlight/treeview/not-fired-raddraganddropmanager-adddragqueryhandler-this-treesource-ondragquery.aspx

Apparently I needed to add the last parameter of true when adding the handler:
UnitTree.AddHandler(RadDragAndDropManager.DropQueryEvent, new EventHandler<DragDropQueryEventArgs>(UnitTree_DropQuery), true);

Tags
TreeView
Asked by
Rodd
Top achievements
Rank 1
Answers by
Rodd
Top achievements
Rank 1
Share this question
or