2010-08-17 63 views
0
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我能轉換:需要的VB相當於

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

這是正確的等值?

​​
+0

你確定你知道Vector Class/Struct的初始值設定項嗎?你給的初始化方法可能對Vector類/結構體是錯誤的。 – 2010-08-18 08:42:05

+0

我會檢查一下謝謝。 – spafa9 2010-08-18 20:01:35

2

刪除halfSize聲明中的「As Object」。所以它應該是:

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