Sorry for my bad english.
I have the following XAML :
<Window x:Class="Project.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:HelixToolkit="clr-namespace:HelixToolkit.Wpf;assembly=HelixToolkit.Wpf"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ResizeMode="CanResizeWithGrip" WindowStartupLocation="CenterScreen" MinWidth="1024" MinHeight="768" Loaded="Window_Loaded">
<Grid>
<Button Click="Button_Click"/>
<HelixToolkit:HelixViewport3D x:Name="viewport">
<HelixToolkit:HelixViewport3D.Camera>
<OrthographicCamera Position="1, 1, 1" LookDirection="-1, -1, -1" UpDirection="1, 0, 0" />
</HelixToolkit:HelixViewport3D.Camera>
<HelixToolkit:DefaultLights/>
<ModelVisual3D x:Name="elem0"/>
<ModelVisual3D x:Name="elem1"/>
<ModelVisual3D x:Name="elem2"/>
</HelixToolkit:HelixViewport3D>
</Grid>
</Window>
And the following Button_Click :
private void Button_Click()
{
elem0.Children.Add(visual...);
..
elem1.Children.Add(visual...);
..
elem2.Children.Add(visual...);
..
viewport.ZoomExtents();
}
Everything (the draw process) works fine except the viewport.ZoomExtents() in Button_Click(). The Zoom Extent is not done at all.
The ZoomExtents method works if it is called some time after the HelixViewport3D's childrens have been updated. eg If i create a second button where I call only viewport.ZoomExtents() and I click on this button, then the Zoom Extents is done. I have subscribed to all (useful) events of the Viewport and called there viewport.ZoomExtents(). I thought there was an event fired when childrens are "Changed"... but nothing worked...
I tried another solution I found here : Helix 3D Toolkit - ZoomExtents method call works different than activating ZoomExtents through gesture ... but that don't work either (perhaps it worked long time ago but now not).
Do you have any idea to help me ?
Thank you.