@@ -28,11 +28,11 @@ module DragDropDemo =
2828
2929 let doDrag ( e , dragCount ) =
3030 async {
31- let dragData = DataObject ()
32- dragData.Set ( DataFormats. Text, $" You have dragged text %d {dragCount} times" )
31+ use dragData = new DataTransfer ()
32+ dragData.Add ( DataTransferItem.Create ( DataFormat. Text, $" You have dragged text %d {dragCount} times" ) )
3333
3434 let! result = Dispatcher.UIThread.InvokeAsync< DragDropEffects>
35- ( fun _ -> DragDrop.DoDragDrop ( e, dragData, DragDropEffects.Copy)) |> Async.AwaitTask
35+ ( fun _ -> DragDrop.DoDragDropAsync ( e, dragData, DragDropEffects.Copy)) |> Async.AwaitTask
3636 return match result with
3737 | DragDropEffects.Copy -> " The text was copied"
3838 | DragDropEffects.Link -> " The text was linked"
@@ -83,19 +83,19 @@ module DragDropDemo =
8383 ( TextBlock.create
8484 [ TextBlock.text state.dropText
8585 Control.onDrop ( fun e ->
86- if e.Data .Contains( DataFormats .Text) then
87- Dropped( e.Data.GetText ()) |> dispatch
88- elif e.Data .Contains( DataFormats.Files ) then
86+ if e.DataTransfer .Contains( DataFormat .Text) then
87+ Dropped( e.DataTransfer.TryGetText ()) |> dispatch
88+ elif e.DataTransfer .Contains( DataFormat.File ) then
8989 Dropped
90- ( e.Data.GetFiles ()
90+ ( e.DataTransfer.TryGetFiles ()
9191 |> Seq.map ( fun item -> item.Name)
9292 |> String.concat Environment.NewLine)
9393 |> dispatch
9494 )
9595 Control.onDragOver ( fun e ->
9696 e.DragEffects <-
97- if e.Data .Contains( DataFormats .Text)
98- || e.Data .Contains( DataFormats.Files ) then
97+ if e.DataTransfer .Contains( DataFormat .Text)
98+ || e.DataTransfer .Contains( DataFormat.File ) then
9999 e.DragEffects
100100 &&& ( DragDropEffects.Copy ||| DragDropEffects.Link)
101101 else
0 commit comments