Esempio n. 1
0
 public static void SetConfiguration(DependencyObject dependencyObject, DropConfiguration value)
 {
     if (dependencyObject != null)
     {
         dependencyObject.SetValue(configurationProperty, value);
     }
 }
Esempio n. 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.DragEnterCommand?.Execute(data);
                args.AcceptedOperation = data.AcceptedOperation;
            };

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

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

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