title | description | ms.date | dev_langs | helpviewer_keywords | ms.assetid | |||||
---|---|---|---|---|---|---|---|---|---|---|
How to: Hit Test in a Viewport3D |
Learn how to perform a hit test for 3D Visuals in the bounds of a Viewport3D element containing 2D and 3D information. |
03/30/2017 |
|
|
42bfbd99-c7c6-43f1-940b-90448faa412e |
This example shows how to hit test for 3D Visuals in a xref:System.Windows.Controls.Viewport3D.
Because xref:System.Windows.Media.VisualTreeHelper.HitTest%2A returns 2D and 3D information, it is possible to iterate through the test results to read only 3D results.
[!code-csharpHitTest3D#HitTest3D3DN4] [!code-vbHitTest3D#HitTest3D3DN4]
The xref:System.Windows.Media.HitTestResultBehavior in the following code determines how the hit test results are processed. UpdateResultInfo
and UpdateMaterial
are locally defined methods.
[!code-csharpHitTest3D#HitTest3D3DN5] [!code-vbHitTest3D#HitTest3D3DN5]