Reputation: 41
i have the problem that my UWP app does not allow me to drop something in (i set AllowDrop="True" everywhere). My DragOver event never triggers and if i try and drop something there is that little red crossed circle that tells me i can't. Honestly i am absolutely clueless as to why. Here is the construct of my UWP code (i removed every unnecessary bit of code so that there is mostly structure left):
<RelativePanel x:Name="ParentPanel" AllowDrop="True">
<RelativePanel AllowDrop="True">
<RelativePanel>
<RelativePanel>
</RelativePanel>
<RelativePanel>
</RelativePanel>
<RelativePanel>
</RelativePanel>
<RelativePanel>
</RelativePanel>
<RelativePanel>
</RelativePanel>
</RelativePanel>
<RelativePanel>
<RelativePanel>
</RelativePanel>
<RelativePanel>
</RelativePanel>
</RelativePanel>
<RelativePanel AllowDrop="True">
<ScrollViewer AllowDrop="True">
<RelativePanel AllowDrop="True">
<RelativePanel AllowDrop="True">
<RelativePanel AllowDrop="True">
<Image Height="150" Width="150" Margin="2" AllowDrop="True" DragOver="onDragOver"/>
</RelativePanel>
<RelativePanel AllowDrop="True">
<Image Height="150" Width="150" Margin="2" AllowDrop="True" DragOver="onDragOver"/>
</RelativePanel>
</RelativePanel>
</RelativePanel>
</RelativePanel>
</ScrollViewer>
</RelativePanel>
</RelativePanel>
</RelativePanel>
And here is the onDragOver event Code (which never gets triggered because it seems like my app does not allow Drops):
private void onDragOver(object sender, DragEventArgs e)
{
e.AcceptedOperation = DataPackageOperation.Copy;
}
The core of the Question: How do i get my Application to allow the drop operation?
Thank you in advance
Upvotes: 0
Views: 34
Reputation: 32785
Image Drop in UWP surrounded by Relative Panels
The problem is that you have not set the Source for image, and the image control will not render. Even the element has drag over, onDragOver event will not be triggered. So please set a placeholder image source to make image rendered.
<Image
Width="150"
Height="150"
Margin="2"
Source="ms-appx:///Assets/StoreLogo.png"
AllowDrop="True"
DragOver="onDragOver" />
Upvotes: 0