Exemple #1
0
 public static void SetConfiguration(DependencyObject dependencyObject, DropConfiguration value)
 {
     if (dependencyObject != null)
     {
         dependencyObject.SetValue(configurationProperty, value);
     }
 }
Exemple #2
0
        private static void ConfigureUIElement(UIElement element, DropConfiguration configuration)
        {
            element.DragEnter += (sender, args) =>
            {
                // Operation is copy by default
                args.AcceptedOperation = DataPackageOperation.Copy;

                var data = new DragDropData {
                    AcceptedOperation = args.AcceptedOperation, DataView = args.DataView
                };
                configuration.DragEnterAction?.Invoke(data);
                args.AcceptedOperation = data.AcceptedOperation;
            };

            element.DragOver += (sender, args) =>
            {
                var data = new DragDropData {
                    AcceptedOperation = args.AcceptedOperation, DataView = args.DataView
                };
                configuration.DragOverAction?.Invoke(data);
                args.AcceptedOperation = data.AcceptedOperation;
            };

            element.DragLeave += (sender, args) =>
            {
                var data = new DragDropData {
                    AcceptedOperation = args.AcceptedOperation, DataView = args.DataView
                };
                configuration.DragLeaveAction?.Invoke(data);
            };

            element.Drop += async(sender, args) =>
            {
                await configuration.ProcessComandsAsync(args.DataView);
            };
        }