--- title: "How to: Hit Test Geometry in a Visual" ms.date: "03/30/2017" dev_langs: - "csharp" - "vb" helpviewer_keywords: - "hit tests [WPF], on visual objects comprising Geometry objects [WPF]" - "visual objects [WPF], hit tests on" - "Geometry objects [WPF], visual objects comprising" ms.assetid: 8bf2643f-d7f9-4cb4-9ea6-5b893c23200d --- # How to: Hit Test Geometry in a Visual This example shows how to perform a hit test on a visual object that is composed of one or more objects. ## Example The following example shows how to retrieve the from a visual object that uses the method. A hit test is then performed on the rendered content of each drawing in the to determine which geometry was hit. > [!NOTE] > In most cases, you would use the method to determine whether a point intersects any of the rendered content of a visual. [!code-csharp[VisualsOverview#VisualsOverviewSnippet4](~/samples/snippets/csharp/VS_Snippets_Wpf/VisualsOverview/CSharp/Window1.xaml.cs#visualsoverviewsnippet4)] [!code-vb[VisualsOverview#VisualsOverviewSnippet4](~/samples/snippets/visualbasic/VS_Snippets_Wpf/VisualsOverview/visualbasic/window1.xaml.vb#visualsoverviewsnippet4)] The method is an overloaded method that allows you to hit test by using a specified or . If a geometry is stroked, the stroke can extend outside the fill bounds. In which case, you may want to call in addition to . You can also provide a that is used for the purposes of Bezier flattening. > [!NOTE] > This sample does not take into account any transforms or clipping that may be applied to the geometry. In addition, this sample will not work with a styled control, since it does not have any drawings directly associated with it. ## See also - [Hit Testing in the Visual Layer](hit-testing-in-the-visual-layer.md) - [Hit Test Using Geometry as a Parameter](how-to-hit-test-using-geometry-as-a-parameter.md)