如何传递以下参数? VisualTreeHelper.HitTest(,,,)中的HitTestParameters3D?

时间:2023-01-28 00:22:09

I am trying to pass the HitTestParameters3D parameter to VisualTreeHelper.HitTest(,,,) but I've failed to find any examples as to how this can be done and information about HitTestParameters3D is scant.

我试图将HitTestParameters3D参数传递给VisualTreeHelper.HitTest(,,,),但我没有找到任何关于如何做到这一点的例子,而且关于HitTestParameters3D的信息很少。

Help is appreciated.

感谢帮助。

Thanks

Q

1 个解决方案

#1


Use RayHitTestParameters class for the parameter.

使用RayHitTestParameters类作为参数。

RayHitTestParameters hitParams = 
        new RayHitTestParameters(
            new Point3D(0, 0, 0),
            new Vector3D(1, 0, 0)
            );
    VisualTreeHelper.HitTest(visual3d, null, ResultCallback, hitParams);

Make sure to pass a Visual3D (for example, a ModelVisual3D) and not your Viewport3D as that first parameter to HitTest. Otherwise, you'll get a "cannot convert from RayHitTestParameters to HitTestParameters" error.

确保将Visual3D(例如,ModelVisual3D)而不是Viewport3D作为第一个参数传递给HitTest。否则,您将获得“无法从RayHitTestParameters转换为HitTestParameters”错误。

#1


Use RayHitTestParameters class for the parameter.

使用RayHitTestParameters类作为参数。

RayHitTestParameters hitParams = 
        new RayHitTestParameters(
            new Point3D(0, 0, 0),
            new Vector3D(1, 0, 0)
            );
    VisualTreeHelper.HitTest(visual3d, null, ResultCallback, hitParams);

Make sure to pass a Visual3D (for example, a ModelVisual3D) and not your Viewport3D as that first parameter to HitTest. Otherwise, you'll get a "cannot convert from RayHitTestParameters to HitTestParameters" error.

确保将Visual3D(例如,ModelVisual3D)而不是Viewport3D作为第一个参数传递给HitTest。否则,您将获得“无法从RayHitTestParameters转换为HitTestParameters”错误。