private void MoveThumb( Thumb thumb, Point position )
{
var element = AdornedElement as FrameworkElement;
position = new Point( position.X * element.ActualWidth, position.Y * element.ActualHeight );
**var halfSize = (Vector)thumb.DesiredSize / 2;**
thumb.Arrange( new Rect( position - halfSize, position + halfSize ) );
}
这是我能够转换的VB.net:
Private Sub MoveThumb(ByVal thumb As Thumb, ByVal position As Point)
Dim element = TryCast(AdornedElement, FrameworkElement)
position = New Point(position.X * element.ActualWidth, position.Y * element.ActualHeight)
Dim halfSize As Object = DirectCast(thumb.DesiredSize, Vector) / 2
thumb.Arrange(New Rect(position - halfSize, position + halfSize))
End Sub
它说无法将window.size转换为window.vector
任何人都可以帮助我。
感谢,
答案 0 :(得分:2)
删除halfSize声明中的“As Object”。所以它应该是:
dim halfSize = DirectCast(thumb.DesiredSize, Vector) / 2
答案 1 :(得分:0)
这是正确的等价物吗?
Dim halfSize As Vector = New Vector(thumb.DesiredSize.Height / 2, thumb.DesiredSize.Width / 2)