So I have this xaml code in my "view" assembly:
<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>
in "view-model" assembly I am loading some data into ScatterPlotVisual3D which creates new plot (displaying some points, boundarybox, labels, etc):
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;
}
So what I need to do is force HelixViewport3D into "doing" ZoomExtents() (or any other similar way of zooming camera to fit model) when I load my data.
Problem: I cant call ZoomExtents() as I dont have any reference to helix:HelixViewport3D declared in my XAML
I just added event to my ScatterPlotVisual3D and assigned this event in xaml to private function of view, which has access to HelixViewport3D and calls ZoomExtents() on it. Now I call my event when I load my data