tags:

views:

47

answers:

2
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 ) );
}

This is the VB.net I am able to convert:

    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

It is saying unable to convert window.size to window.vector

Can anyone help me with this.

thanks,

A: 

Would this be the correct equivalent?

Dim halfSize As Vector = New Vector(thumb.DesiredSize.Height / 2, thumb.DesiredSize.Width / 2)
spafa9
Are you sure you know the initializer of the Vector Class/Struct? The initializer you gave could be wrong for the Vector Class/Struct.
Alex Essilfie
I will check thank you.
spafa9
+2  A: 

Remove the "As Object" in the declaration of halfSize. So it should read:

dim halfSize = DirectCast(thumb.DesiredSize, Vector) / 2 
icemanind