I’m dropping an object (ScatterViewItem) on a SurfaceListBox with the s:SurfaceDragDrop event, and it works fine when detecting the dropping on the whole SurfaceListBox, however, I want to know in which SurfaceListBoxItem the object was dropped.
I also want to do this but for a ScatterView, i.e., detecting which ScatterViewItem of that ScatterView the object was dropped on.
My code is something like this:
<s:SurfaceListBox
x:Name="listBoxList"
Background="{x:Null}"
AllowDrop="True"
s:SurfaceDragDrop.Drop="ListBox_Drop" >
</s:SurfaceListBox>
<s:ScatterView
x:Name="scatterList"
Background="{x:Null}"
AllowDrop="True"
s:SurfaceDragDrop.Drop="Scatter_Drop" >
</s:ScatterView>
And then I add my items:
listBoxList.Items.Add("ListBox Item 1");
listBoxList.Items.Add("ListBox Item 1");
listBoxList.Items.Add("ListBox Item 1");
scatterList.Items.Add("ScatterViewItem A");
scatterList.Items.Add("ScatterViewItem B");
scatterList.Items.Add("ScatterViewItem C");
So how can I get the item on the ListBox_Drop and Scatter_Drop?
EDIT
Through Robert answer I managed to solve my problem. So the resulting code would be something like this (for the ScatterView):
<s:ScatterView
x:Name="scatterList"
Background="{x:Null}">
<s:ScatterView.ItemContainerStyle>
<Style TargetType="s:ScatterViewItem">
<EventSetter Event="s:SurfaceDragDrop.Drop" Handler="Scatter_Drop"/>
<Setter Property="AllowDrop" Value="True" />
</Style>
</s:ScatterView.ItemContainerStyle>
</s:ScatterView>
And for the SurfaceListBox:
<s:SurfaceListBox
x:Name="listBoxList"
Background="{x:Null}">
<s:SurfaceListBox.ItemContainerStyle>
<Style TargetType="s:SurfaceListBox">
<EventSetter Event="s:SurfaceDragDrop.Drop" Handler="ListBox_Drop"/>
<Setter Property="AllowDrop" Value="True" />
</Style>
</s:SurfaceListBox.ItemContainerStyle>
</s:SurfaceListBox>
You need to set
AllowDropand hook up your Drop event handler for each individualScatterViewItem&ListBoxItem. Then the source of the event will be the item that got dropped upon.