开发者

Need the VB equivalent

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,


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

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


Would this be the correct equivalent?

Dim halfSize As Vector = New Vector(thumb.DesiredSize.Height / 2, thumb.DesiredSize.Width / 2)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜