Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set DragUI visual. #10144

Open
Gavin-Williams opened this issue Nov 8, 2024 · 2 comments
Open

Cannot set DragUI visual. #10144

Gavin-Williams opened this issue Nov 8, 2024 · 2 comments
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners

Comments

@Gavin-Williams
Copy link

Gavin-Williams commented Nov 8, 2024

Describe the bug

When I set the visual for a drag and drop operation using...

args.DragUI.SetContentFromBitmapImage(bmp);

The image is not visible.

Steps to reproduce the bug

  1. Create a handler for DragStarting
  2. Provide a BitmapImage as a source image
  3. Set the visual.

Expected behavior

I expect to see the image.

Screenshots

Image

NuGet package version

WinUI 3 - Windows App SDK 1.6.1: 1.6.240923002

Windows version

Windows 11 (22H2): Build 22621

Additional context

DragUI.SetContentFromSoftwareBitmap() does not show the bitmap #4528

DataGridRow Drag and Drop Visual does not display most of the time #4545

@Gavin-Williams Gavin-Williams added the bug Something isn't working label Nov 8, 2024
@Gavin-Williams Gavin-Williams changed the title Bug title Cannot set DragUI visual. Nov 8, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Nov 8, 2024
@castorix
Copy link

castorix commented Nov 8, 2024

I works on my Windows 10 22H2 OS, Windows App SDK 1.6.240829007 :

    private void Img1_DragStarting(UIElement sender, DragStartingEventArgs args)
    {
        args.AllowedOperations = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
        args.DragUI.SetContentFromBitmapImage(new BitmapImage(new Uri("ms-appx:///Assets/ButterflyBlue_small.png", UriKind.RelativeOrAbsolute)));
    }

Image

@Gavin-Williams
Copy link
Author

Gavin-Williams commented Nov 8, 2024

@castorix that works for me too. Ok, I've found the case where it doesn't work, and maybe there's something I don't understand about WinUI. If I use the BitmapImage beforehand as a source for another Image control, it doesn't work.

TestImage.Source = GlobalBitmapImage; // I see this.
args.DragUI.SetContentFromBitmapImage(GlobalBitmapImage); // I don't see this

Copilot and other resources say that I can use BitmapImage as a source for multiple items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-triage Issue needs to be triaged by the area owners
Projects
None yet
Development

No branches or pull requests

2 participants