Skip to content

Nested ItemsControl with DragSourceIgnored #513

@miladesign

Description

@miladesign

Hi. i have problem with DragSourceIgnored when use ItemsControl inside another ItemsControl.
so i want to drag drop itemsControl item with button that inside item. it work for outer ItemsControl but inner one not working.
this is edited sample from source code:

<ItemsControl Height="Auto"
              dd:DragDrop.DragAdornerTemplate="{StaticResource DragAdorner}"
              dd:DragDrop.DragDropContext="OuterContext"
              dd:DragDrop.IsDragSource="True"
              dd:DragDrop.IsDropTarget="True"
              dd:DragDrop.UseDefaultEffectDataTemplate="True"
              ItemsSource="{Binding Data.Collection1}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Grid Margin="0 1 0 1" Background="Coral" dd:DragDrop.DragSourceIgnore="True">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Button Grid.Row="0" dd:DragDrop.DragSourceIgnore="False"
                        Margin="2"
                        FontSize="16"
                        Content="{Binding}" />
                <ItemsControl Grid.Row="1"
                              Height="Auto"
                              dd:DragDrop.DragDropContext="InnerContext"
                              dd:DragDrop.IsDragSource="True"
                              dd:DragDrop.IsDropTarget="True"
                              ItemsSource="{Binding SubItemCollection, Mode=OneWay}">
                    <ItemsControl.ItemTemplate>
                        <DataTemplate DataType="{x:Type models:SubItemModel}">
                            <Grid Background="#FDA07E" dd:DragDrop.DragSourceIgnore="True">
                                <StackPanel Orientation="Horizontal">
                                    <Button Margin="20 0 10 0" dd:DragDrop.DragSourceIgnore="False"
                                            VerticalAlignment="Center"
                                            Command="{Binding ButtonTestCommand}"
                                            Content="{Binding Caption}" />
                                    <RadioButton VerticalAlignment="Center"
                                                 Content="Option A"
                                                 IsChecked="{Binding BindableOptionA}" />
                                    <RadioButton VerticalAlignment="Center"
                                                 Content="Option B"
                                                 IsChecked="{Binding BindableOptionB}" />
                                    <TextBlock VerticalAlignment="Center" Text="{Binding BindableValue}" />
                                </StackPanel>
                            </Grid>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </Grid>
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>

when i remove DragSourceIgnore or make it false its work, but all item become draggable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions