Dragging of a disabled Item

5 posts, 0 answers
  1. Sternico
    Sternico avatar
    25 posts
    Member since:
    Sep 2009

    Posted 11 May 2011 Link to this post

    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
  2. Tsvyatko
    Admin
    Tsvyatko avatar
    833 posts

    Posted 11 May 2011 Link to this post

    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
  3. DevCraft banner
  4. Sternico
    Sternico avatar
    25 posts
    Member since:
    Sep 2009

    Posted 11 May 2011 Link to this post

    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?
  5. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 12 May 2011 Link to this post

    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
  6. Sternico
    Sternico avatar
    25 posts
    Member since:
    Sep 2009

    Posted 12 May 2011 Link to this post

    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
Back to Top
DevCraft banner