Beispiel #1
0
        void HandleDrop(object sender, Microsoft.UI.Xaml.DragEventArgs e)
        {
            var           datapackage = e.DataView.Properties["_XFPropertes_DONTUSE"] as DataPackage;
            VisualElement element     = null;

            if (sender is IVisualElementRenderer renderer)
            {
                element = renderer.Element;
            }

            var args = new DropEventArgs(datapackage?.View);

            SendEventArgs <DropGestureRecognizer>(async rec =>
            {
                if (!rec.AllowDrop)
                {
                    return;
                }

                try
                {
                    await rec.SendDrop(args);
                }
                catch (Exception dropExc)
                {
                    Internals.Log.Warning(nameof(DropGestureRecognizer), $"{dropExc}");
                }
            });
        }
Beispiel #2
0
        void HandleDragLeave(object sender, Microsoft.UI.Xaml.DragEventArgs e)
        {
            var package       = e.DataView.Properties["_XFPropertes_DONTUSE"] as DataPackage;
            var dragEventArgs = new DragEventArgs(package);

            dragEventArgs.AcceptedOperation = (DataPackageOperation)((int)dragEventArgs.AcceptedOperation);
            SendEventArgs <DropGestureRecognizer>(rec =>
            {
                if (!rec.AllowDrop)
                {
                    return;
                }

                var operationPriorToSend = dragEventArgs.AcceptedOperation;
                rec.SendDragLeave(dragEventArgs);

                // If you set the AcceptedOperation to a value it was already set to
                // it causes the related animation to remain visible when the dragging component leaves
                // for example
                // e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
                // Even if AcceptedOperation is already set to Copy it will cause the copy animation
                // to remain even after the the dragged element has left
                if (operationPriorToSend != dragEventArgs.AcceptedOperation)
                {
                    var result          = (int)dragEventArgs.AcceptedOperation;
                    e.AcceptedOperation = (Windows.ApplicationModel.DataTransfer.DataPackageOperation)result;
                }
            });
        }
Beispiel #3
0
        void HandleDragOver(object sender, Microsoft.UI.Xaml.DragEventArgs e)
        {
            var package       = e.DataView.Properties["_XFPropertes_DONTUSE"] as DataPackage;
            var dragEventArgs = new DragEventArgs(package);

            SendEventArgs <DropGestureRecognizer>(rec =>
            {
                if (!rec.AllowDrop)
                {
                    e.AcceptedOperation = Windows.ApplicationModel.DataTransfer.DataPackageOperation.None;
                    return;
                }

                rec.SendDragOver(dragEventArgs);
                var result          = (int)dragEventArgs.AcceptedOperation;
                e.AcceptedOperation = (Windows.ApplicationModel.DataTransfer.DataPackageOperation)result;
            });
        }
Beispiel #4
0
        void HandleDrop(object sender, Microsoft.UI.Xaml.DragEventArgs e)
        {
            var datapackage = e.DataView.Properties["_XFPropertes_DONTUSE"] as DataPackage;

            var args = new DropEventArgs(datapackage?.View);

            SendEventArgs <DropGestureRecognizer>(async rec =>
            {
                if (!rec.AllowDrop)
                {
                    return;
                }

                try
                {
                    await rec.SendDrop(args);
                }
                catch (Exception dropExc)
                {
                    Application.Current?.FindMauiContext()?.CreateLogger <DropGestureRecognizer>()?.LogWarning(dropExc, "Error sending drop event");
                }
            });
        }