RadDragDropManager with hierarchical TreeView not firing DropQueryEvent?

2 posts, 0 answers
  1. Rodd
    Rodd avatar
    7 posts
    Member since:
    Jul 2010

    Posted 25 Aug 2011 Link to this post

    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}}"
                         SelectedItem="{Binding SelectedUnit, Mode=TwoWay}"
                         BorderBrush="Black" BorderThickness="1" Margin="5"
                         IsDragDropEnabled="True" IsDragPreviewEnabled="True"
        <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}}"/>
                    <TextBlock Text="{Binding UnitType}" FontStyle="Italic" FontSize="10" Foreground="Gray" FontWeight="Bold" />

    and this in my code behind
        public partial class EntityNavigator : UserControl
            public EntityNavigator()
                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.
  2. Rodd
    Rodd avatar
    7 posts
    Member since:
    Jul 2010

    Posted 25 Aug 2011 Link to this post

    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);

Back to Top