コード例 #1
0
ファイル: DragDropService.cs プロジェクト: baku2san/StudyUWP
 public static void SetConfiguration(DependencyObject dependencyObject, DropConfiguration value)
 {
     if (dependencyObject != null)
     {
         dependencyObject.SetValue(configurationProperty, value);
     }
 }
コード例 #2
0
ファイル: DragDropService.cs プロジェクト: baku2san/StudyUWP
        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);
            };
        }