AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.98k stars 2.25k forks source link

Issue when drag one file from Finder to App #15715

Open Tenjim opened 6 months ago

Tenjim commented 6 months ago

Describe the bug

After Investigation, I have issue when we drag a file from Finder and drop on Avalonia App. I'm using DragAndDrop Behavior from this repo. I have notice that when we do an DragEnter, we are looking to get a DataObject and there is en exception on Avalonia native clipboard:

System.Runtime.InteropServices.COMException (0x80004005): GetBytes failed at Avalonia.Native.Interop.Impl.__MicroComIAvnClipboardProxy.GetBytes(String type) at Avalonia.Native.ClipboardImpl.GetDataAsync(String format) at Avalonia.Native.ClipboardDataObject.Get(String dataFormat) at Avalonia.Xaml.Interactions.DragAndDrop.ContextDropBehavior.DragEnter(Object sender, DragEventArgs e)

To Reproduce

Using DragAndDrop Behaviour, use it on an listbox. Drag one file from Finder App to listboxItem.

Expected behavior

doing drop behavior

Avalonia version

11.0.10

OS

macOS

Additional context

No response

timunie commented 6 months ago

did you mark the thread as [STAThread]?

    [STAThread]
    public static void Main(string[] args)
 ...
Tenjim commented 6 months ago

HI @timunie , yes I did it on my main method

timunie commented 6 months ago

Can you do us a favor and test vanilla Avalonia Drag & Drop? I have no mac, so can't do it on my own. If you can reproduce there, upload the sample please

Tenjim commented 6 months ago

Hi I'll close this ticket, with investigation, it's came to DragAndDrop from Avalonia Xaml Behaviour. I'll follow up on his side. It's work well with vanilla Drag and drop

Tenjim commented 5 months ago

@timunie ,

As requested, I have reproduce that issue on my sample based on ControlCatalog from Avalonia samples here.

To see what I have, you need just to drag a file from finder on DragMeCustom Textblock.