--- title: "How to: Hit Test Using Geometry as a Parameter" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "hit tests [WPF], on visual objects using Geometry objects [WPF]" - "visual objects [WPF], hit tests on" - "Geometry objects [WPF], hit tests on visual objects [WPF]" ms.assetid: 6c8bdbf2-19e0-4fbb-bf89-c1252b2ebc61 --- # How to: Hit Test Using Geometry as a Parameter This example shows how to perform a hit test on a visual object using a as a hit test parameter. ## Example The following example shows how to set up a hit test using for the method. The value that is passed to the `OnMouseDown` method is used to create a object in order to expand the range of the hit test. [!code-csharp[HitTestingOverview#HitTestingOverviewSnippet10](~/samples/snippets/csharp/VS_Snippets_Wpf/HitTestingOverview/CSharp/GeometryHitTest.cs#hittestingoverviewsnippet10)] [!code-vb[HitTestingOverview#HitTestingOverviewSnippet10](~/samples/snippets/visualbasic/VS_Snippets_Wpf/HitTestingOverview/visualbasic/geometryhittest.vb#hittestingoverviewsnippet10)] The property of provides information about the results of a hit test that uses a as a hit test parameter. The following illustration shows the relationship between the hit test geometry (the blue circle) and the rendered content of the target visual object (the red square). ![Diagram that shows IntersectionDetail used in hit testing.](./media/how-to-hit-test-using-geometry-as-a-parameter/intersectiondetail-hit-test.png) The following example shows how to implement a hit test callback when a is used as a hit test parameter. The `result` parameter is cast to a in order to retrieve the value of the property. The property value allows you to determine if the hit test parameter is fully or partially contained within the rendered content of the hit test target. In this case, the sample code is only adding hit test results to the list for visuals that are fully contained within the target boundary. [!code-csharp[HitTestingOverview#HitTestingOverviewSnippet11](~/samples/snippets/csharp/VS_Snippets_Wpf/HitTestingOverview/CSharp/GeometryHitTest.cs#hittestingoverviewsnippet11)] [!code-vb[HitTestingOverview#HitTestingOverviewSnippet11](~/samples/snippets/visualbasic/VS_Snippets_Wpf/HitTestingOverview/visualbasic/geometryhittest.vb#hittestingoverviewsnippet11)] > [!NOTE] > The callback should not be called when the intersection detail is . ## See also - [Hit Testing in the Visual Layer](hit-testing-in-the-visual-layer.md) - [Hit Test Geometry in a Visual](how-to-hit-test-geometry-in-a-visual.md)