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

Dragging of a disabled Item

4 Answers 51 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Sternico
Top achievements
Rank 1
Sternico asked on 11 May 2011, 02:26 PM
Hello. I'm using the telerik Drag&Drop within a ListBox which has enabled and disabled items. Naturally I don't want to allow dragging of the disabled items. The behaviour while using the Drag&Drop in this situation is unsatisfactory. I'm using the Drag&Drop the same way like in the example, where the selected item of the listbox is used to start the dragging. Since the item is disabled, the item is not selecting on a click and the dragging starts with a previously selected item.
Do you have a solution for this problem? The best behaviour would be, if the listbox did not start a dragging while the mousebutton was pressed on a disabled item (or the dragStatus would be different.

Best wishes,

Marco

4 Answers, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 11 May 2011, 02:37 PM
Hello Sternico,

 You can allow or restrict drag operation in DragQuery event. In your scenario the code will be something like the one below:

if(e.Options.Status==DragStatus.DragQuery)
{
   var listItem = e.Options.Source as ListBoxItem;
   if(listItem!=null && listItem.IsDisabled)
   {
      e.QueryResult = false;
      return;
   }
 
}

More information about the drag drop logic can be found in our online documentation.

If you have any further questions do not hesitate to contact us.

Kind regards,
Tsvyatko
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
0
Sternico
Top achievements
Rank 1
answered on 11 May 2011, 05:25 PM
Hello,

thank you for your quick reply. I'm allready using the DragQuery-Event but the e.Option.Source is not the ListBoxItem, but the ListBox. Do I register the events the from way?
0
Milan
Telerik team
answered on 12 May 2011, 08:16 AM

Hi Sternico,

Could you please make sure that the ListBoxItem are marked with AllowDrop=true. You could do this with a simple style:

<Grid>
    <Grid.Resources>
        <Style TargetType="Control" x:Key="DraggableItem">
            <Setter Property="telerikDragDrop:RadDragAndDropManager.AllowDrag" Value="True" />
            <Setter Property="Background" Value="Transparent"/>
        </Style>
    </Grid.Resources>
      
    <ListBox x:Name="myListBox" ItemContainerStyle="{StaticResource DraggableItem}"/>
      
</Grid>

The style also makes sure that the items have a Transparent background. If there is not background you will not be able to perform drag operations.



Best wishes,
Milan
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
0
Sternico
Top achievements
Rank 1
answered on 12 May 2011, 02:53 PM
Hi,
I've set the RadDragAndDropManager.AllowDrag-Property on the ListBox and so the source was the ListBox. Thank you for your solution.

Best wishes,

Marco
Tags
DragAndDrop
Asked by
Sternico
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Sternico
Top achievements
Rank 1
Milan
Telerik team
Share this question
or