Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
806 views
in Technique[技术] by (71.8m points)

uwp - Drag accepted operation not observed

Rather strange but I'm at my wit's end. I have this DragOver handler, practically out of the book:

  e.DragUIOverride.Caption = "my text";
  var op = DataPackageOperation.None;

  if (e.DataView.Contains(StandardDataFormats.StorageItems)) {
    var items = await e.DataView.GetStorageItemsAsync();
    if (items.Any()) {
      var file = items.First() as StorageFile;
      op = (file?.FileType == ".myext") ? DataPackageOperation.Copy : DataPackageOperation.None;
    }
  }

  System.Diagnostics.Trace.WriteLine(op);
  e.AcceptedOperation = op;

The reason for op is to avoid setting the AcceptedOperation twice (not normally required in samples but one of my desperate attempts). The trace at the end shows that this code sets the exact operation I need, no chance of failure. Yet, when running, all I get is a No Entry sign denoting a denied drag operation.

W10 20H2, for what it's worth.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...