ตัวโค๊ดที่ใช้ในการสร้างภาพ
<ex.Extension()> Function Image(ByVal Data As sw.FrameworkElement, _
Optional ByVal DpiX# = 96, Optional ByVal DpiY# = 96) _
As swm.Imaging.RenderTargetBitmap
With Data
Image = New swm.Imaging.RenderTargetBitmap( _
.ActualWidth, .ActualHeight, _
DpiX, DpiY, swm.PixelFormats.Pbgra32)
Image.Render(Data)
End With
End Function
ผมกำลังทำให้การ Drag&Drop ในโปรแกรม มีไอคอนเหมือนติดเมาส์ไปด้วย
เหมือนใน Explorer ซึ่งการทดสอบตำแหน่งต่างๆ ไม่มีปัญหา
Nomal state.

While mouse on.

Test drag position.

แต่พอใช้รูปแทนปุบ ก็มีปัญหาดังนี้

Code ของ event นี้ครับ
Private Sub ClickLD(ByVal sender As Object, _
ByVal e As sw.Input.MouseButtonEventArgs)
'C.F ^ Sender == Dircast(sender,Frameworkelement)
Dim Frame = C.F ^ sender
Dim Ex = Frame.Image
Dim EF = RealPosition(Frame, e)
With MoveIcon
.Height = Ex.Height
.Width = Ex.Width
.Source = Ex
.Margin = New Double() {EF.X, EF.Y, 0, 0}.Margin
End With
Dim FF = New swc.Grid With {.Height = Ex.Height, .Width = Ex.Width, _
.Margin = New Double() {EF.X, EF.Y, 0, 0}.Margin}
'FF.Children.Add(MoveIcon)
FF.Background = "FFffffff".Color.Solid
MoveIcon.IsHitTestVisible = False
FF.IsHitTestVisible = False
AutoSet.AsForm = New PackOf.Frame + MoveIcon + FF
'Use FF insert MoveIcon for test.
ReItem = MoveIcon
MoveOnPanel.Children.Add(ReItem)
With ReItem
.DataContext = EF
.CaptureMouse()
AddHandler .PreviewMouseMove, AddressOf Move
AddHandler .MouseLeftButtonUp, AddressOf ClickLT
End With
End Sub