Drag and Drop Behaviors with ComboBoxes

3 posts, 0 answers
  1. Jacob
    Jacob avatar
    2 posts
    Member since:
    Apr 2013

    Posted 28 Apr 2013 Link to this post

    I have a RadListBox with an overrided ItemTemplate that uses a RadComboBox as one of its elements. When the combo box's scroll bar is visible, attempting to scroll triggers the drag process in the RadListBox. When I disable drag and drop completely, I am not able to scroll - it appears that the relevant mouse events are being captured by the RadListBox.

    Here is the code for the listbox:

    <telerik:RadListBox Name="rlbSpices" QueryContinueDrag="rlbSpices_QueryContinueDrag"  telerik:DragDropManager.AllowDrag="True" AllowDrop="True" ScrollViewer.HorizontalScrollBarVisibility="Disabled" Grid.Row="1" Grid.Column="1" Margin="5" ItemsSource="{Binding RecipeSpices, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
        HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemTemplate="{StaticResource SpiceItemTemplate}">
            <telerik:ScreenshotDragVisualProvider />
            <telerik:ListBoxDragDropBehavior AllowReorder="True"  />

    Here is the code for the item template:

    <DataTemplate x:Key="SpiceItemTemplate">
        <Grid HorizontalAlignment="Stretch">
                <ColumnDefinition Width="100"/>
                <ColumnDefinition Width="50"/>
                <ColumnDefinition Width="30"/>
                <ColumnDefinition Width="25"/>
            <local:IngredientCombobox Loaded="IngredientCombobox_Loaded" PreviewMouseMove="IngredientCombobox_PreviewMouseMove" MouseMove="IngredientCombobox_MouseMove" DropDownOpened="IngredientCombobox_DropDownOpened" DropDownClosed="IngredientCombobox_DropDownClosed" Height="20" VerticalAlignment="Top" Grid.Column="0" SelectedItem="{Binding Spice}"/>
            <xctk:DoubleUpDown Grid.Column="1" Height="20" Width="50" Margin="0,0,0,0" VerticalAlignment="Top" FormatString="F2" Value="{Binding Amount}" Increment=".01"  Maximum="1000.00" />
            <TextBlock Grid.Column="2" Margin="5,0,0,0" Text="{Binding Unit.Name}"/>
            <Button Grid.Column="3" Width="25" Height="25" Name="btnRecipeSpiceDelete" Click="btnRecipeSpiceDelete_Click">X</Button>

    I've tried tracking when a combobox is expanded so that I can disable drag/drop at that time, but there seems to be no way to do that effectively. What is the correct way to handle this issue?
  2. Jacob
    Jacob avatar
    2 posts
    Member since:
    Apr 2013

    Posted 28 Apr 2013 Link to this post

    I got this to work with the following handlers:

    private void IngredientCombobox_DropDownOpened(object sender, EventArgs e)
        var item = ((FrameworkElement)sender).GetVisualParent<RadListBoxItem>();
        DragDropManager.SetAllowDrag(item, false);
        _isIngredientDropdownOpen = true;
    private void IngredientCombobox_DropDownClosed(object sender, EventArgs e)
        var item = ((FrameworkElement)sender).GetVisualParent<RadListBoxItem>();
        DragDropManager.SetAllowDrag(item, true);
        _isIngredientDropdownOpen = false;
  3. Steven
    Steven avatar
    10 posts
    Member since:
    Mar 2011

    Posted 06 Aug 2014 in reply to Jacob Link to this post

    I realise this is an old post, but I was having almost the exact same issue, albeit using the code from the following: http://www.telerik.com/help/wpf/radlistbox-features-dragdrop.html

    The fix for me was to change the overridden RadListBoxItemStyle to use DragDropManager.AllowDrag in place of AllowCapturedDrag, which then allows the mouse drag events on the items in the template itself.

    Note that the OP has added the DragDropManager attached property to the entire RadListBox rather than the items themselves, which may be why it was causing issues in that case.
Back to Top