You can filter the dragged files in DragEnter. This version accepts PNG and JPEG files and rejects the entire drop if any dragged file has another extension:
Event DragEnter(x As Double, y As Double, data As DragData)
data.AcceptDrop = CanAcceptDrop(data)
End Event
Event DragOver(x As Double, y As Double, data As DragData)
data.AcceptDrop = CanAcceptDrop(data)
End Event
Private Function CanAcceptDrop(data As DragData) As Boolean
If Not data.HasFiles Then Return False
For Each path As String In data.Files
Var file As FileSystemItem = New FileSystemItem(path)
Select Case file.Extension
Case "png", "jpg", "jpeg"
# This file is supported.
Else
Return False
End Select
Next
Return True
End Function
Extensions are compared case-insensitively, so files ending in .PNG or .JPG are also accepted.
The DragOver handler is required as a workaround in the current release. I found that an accepted DragEnter decision was being cleared when no DragOver handler existed. This has now been fixed in the next release, after which the DragOver handler will be optional unless you need to change acceptance while the pointer moves.
https://feedback.objo.dev/bug/1355