我有一个位于我的“视图”程序集中的XAML代码:
<helix:HelixViewport3D ZoomExtentsWhenLoaded="True"
ShowCoordinateSystem="True"
IsMoveEnabled="False"
Margin="5,5,5,0">
<helix:HelixViewport3D.Camera>
<OrthographicCamera LookDirection="1,1,-1"
Position="{Binding CameraPosition}"
UpDirection="0,0,1">
</OrthographicCamera>
</helix:HelixViewport3D.Camera>
<ModelVisual3D Content="{Binding Lights}"/>
<local:ScatterPlotVisual3D Points="{Binding Data}"
SolutionPoints="{Binding Solution}"
SurfaceBrush="{Binding SurfaceBrush}"/>
</helix:HelixViewport3D>
在“视图模型”程序集中,我正在将一些数据加载到ScatterPlotVisual3D中,它会创建新的绘图(显示一些点、边界框、标签等):
private Model3D CreateModel()
{
var plotModel = new Model3DGroup();
if (Points == null && SolutionPoints == null) return plotModel;
List<Point3D> allPoints = new List<Point3D>();
if (Points != null && Points.Length != 0)
{
plotModel.Children.Add(CreatePointsModel(Points, Brushes.Green));
allPoints.AddRange(Points);
}
if (SolutionPoints != null && SolutionPoints.Length != 0)
{
plotModel.Children.Add(CreatePointsModel(SolutionPoints, Brushes.Red));
allPoints.AddRange(SolutionPoints);
}
CreateBoundaryAxis(plotModel, allPoints);
return plotModel;
}
我的需要是在加载数据时强制 HelixViewport3D 执行 ZoomExtents()(或任何其他类似的缩放相机以适应模型的方式)。
问题:我无法调用 ZoomExtents(),因为我在 XAML 中没有对 helix:HelixViewport3D 的引用声明。