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

RadTreeView Drag Handlers??

1 Answer 28 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 2
Kevin asked on 28 Jul 2010, 11:53 AM
Guys,

not sure if this is something thats possible, but is it possible to make only certain parts of an item "Draggable"... having an area / control that is the drag point of the control... see exampeitem imaeg for the kinda of area i'm talking about on my control..

Hope this makes sense.

Cheers guys

1 Answer, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 29 Jul 2010, 04:28 PM
Hello Kevin,

Yes, you can achieve this. You can handle the DragQuery event and allow the drag only if the mouse is above a certain element in the ItemTemplate, e.g.;

private void OnDragQuery(object sender, DragDropQueryEventArgs e)
{
    var sourceItem = e.Options.Source as RadTreeViewItem;
  
    // Allow dragging from the drag handle only:
    if (e.QueryResult == true
        && sourceItem != null
        && e.Options.Status == DragStatus.DragQuery)
    {
        var dragHandle = sourceItem.FindChildByType<Button>();
        e.QueryResult = dragHandle.IsMouseOver;
    }
}

Where you register for the event like so:

treeView.AddHandler(RadDragAndDropManager.DragQueryEvent, 
    new EventHandler<DragDropQueryEventArgs>(OnDragQuery), true);

And the ItemTemplate is:

<telerik:HierarchicalDataTemplate ItemsSource="{Binding ChildCategories}">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Button Content="|||" x:Name="dragHandle" />
        <TextBlock Text="{Binding Title}" 
                   Grid.Column="1" Margin="4 2 2 2" 
                   VerticalAlignment="Center"/>
    </Grid>
</telerik:HierarchicalDataTemplate>


Regards,
Miroslav
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
Tags
TreeView
Asked by
Kevin
Top achievements
Rank 2
Answers by
Miroslav
Telerik team
Share this question
or