PointHitTestResult 類別
定義
public ref class PointHitTestResult : System::Windows::Media::HitTestResult
public class PointHitTestResult : System.Windows.Media.HitTestResult
type PointHitTestResult = class
inherit HitTestResult
Public Class PointHitTestResult
Inherits HitTestResult
- 繼承
- 衍生
範例
下列範例顯示如何 PointHitTestResult 從方法中取出傳回值 HitTest 。The following example shows how to retrieve the PointHitTestResult return value from the HitTest method.
// Respond to the left mouse button down event by initiating the hit test.
private void OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// Retrieve the coordinate of the mouse position.
Point pt = e.GetPosition((UIElement)sender);
// Perform the hit test against a given portion of the visual object tree.
HitTestResult result = VisualTreeHelper.HitTest(myCanvas, pt);
if (result != null)
{
// Perform action on hit visual object.
}
}
' Respond to the left mouse button down event by initiating the hit test.
Private Overloads Sub OnMouseLeftButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
' Retrieve the coordinate of the mouse position.
Dim pt As Point = e.GetPosition(CType(sender, UIElement))
' Perform the hit test against a given portion of the visual object tree.
Dim result As HitTestResult = VisualTreeHelper.HitTest(myCanvas, pt)
If result IsNot Nothing Then
' Perform action on hit visual object.
End If
End Sub
備註
您也可以使用 Geometry 做為點擊測試參數,並以的形式傳回結果,對視覺物件執行點擊測試 GeometryHitTestResult 。You can also perform a hit test on a visual object by using a Geometry as a hit test parameter and returning the result as a GeometryHitTestResult. 如需詳細資訊,請參閱 如何:使用 Geometry 做為參數進行點擊測試。For more information, see How to: Hit Test Using Geometry as a Parameter.
建構函式
PointHitTestResult(Visual, Point) |
初始化 PointHitTestResult 類別的新執行個體。Initializes a new instance of the PointHitTestResult class. |
屬性
PointHit |
取得從點擊測試結果傳回的點值。Gets the point value that is returned from a hit test result. |
VisualHit |
取得從點擊測試結果傳回的視覺物件。Gets the visual object that is returned from a hit test result. |
方法
Equals(Object) |
判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object. (繼承來源 Object) |
GetHashCode() |
做為預設雜湊函式。Serves as the default hash function. (繼承來源 Object) |
GetType() |
取得目前執行個體的 Type。Gets the Type of the current instance. (繼承來源 Object) |
MemberwiseClone() |
建立目前 Object 的淺層複製。Creates a shallow copy of the current Object. (繼承來源 Object) |
ToString() |
傳回代表目前物件的字串。Returns a string that represents the current object. (繼承來源 Object) |