I have a ListBox
that is a drop target of items from other sources.
Everything is working fine except in a particularly situation. When the ListBox
has no Items I can only drop in the border of ListBox
(I have a trigger so the Border is visible when dragging).
To give a bigger drop area I set the MinHeight
of the ListBox
to 25. When dragging, the Border reflects the MinHeight
of the ListBox
but the area is not considered a target. What is probably happening is that the target is considered to be the background because there is no Item in the ListBox
.
Here is the code for the ListBox
:
<ListBox Name="itmCtrlSetupSteps" Grid.Row="1" MinHeight="25"
BorderThickness="2" BorderBrush="{Binding DropBrush}" Background="Transparent"
ItemsSource="{Binding SetupSteps}" SelectionMode="Single" ItemContainerStyle="{StaticResource StepItemStyle}"
HorizontalContentAlignment="Stretch" Focusable="True"
SelectionChanged="manageStep_SelectionChanged"
AllowDrop="True" DragOver="itmCtrls_DragOver" Drop="itmCtrls_Drop" KeyUp="List_KeyUp"
>
<ListBox.Template>
<ControlTemplate TargetType="ListBox">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
<ItemsPresenter/>
</Border>
</ControlTemplate>
</ListBox.Template>
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type my:TestStepListingStepViewModel}">
<my:TestStepListingStepView HorizontalAlignment="Stretch" GotFocus="setupSteps_GotFocus" MouseDoubleClick="Step_MouseDoubleClick"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
If I set the ItemPanel to:
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<Grid ClipToBounds="True"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
I can drop items in the empty ListBox
but then the items are presented on top of each other, instead of as a list.
Any thoughts on this?