C# 需要VB的等价物吗
这是我能够转换的VB.net:C# 需要VB的等价物吗,c#,vb.net,C#,Vb.net,这是我能够转换的VB.net: 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 = (Vecto
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 ) );
}
它表示无法将window.size转换为window.vector
有人能帮我吗
谢谢,这是正确的等价物吗
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
删除半尺寸声明中的“作为对象”。因此,它应该是:
Dim halfSize As Vector = New Vector(thumb.DesiredSize.Height / 2, thumb.DesiredSize.Width / 2)
你确定你知道向量类/结构的初始值设定项吗?您为Vector类/结构提供的初始值设定项可能错误。
dim halfSize = DirectCast(thumb.DesiredSize, Vector) / 2