2017-03-09 13 views
2

그래서 나는 "보기"조립이 XAML 코드를 가지고 :WPF 헬릭스 코드에서 뷰포트 3 차원을 "확대/축소"하는 방법은 무엇입니까?

새로운 플롯 (표시를 생성 내가 ScatterPlotVisual3D로 일부 데이터를 로딩하고 "뷰 - 모델"조립 몇 가지 포인트, boundarybox, 라벨 등의
<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> 

) :

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;    
} 

그래서 내가해야 할 일을 힘 "하고"ZoomExtents에 HelixViewport3D() (또는 내 데이터를로드 할 때) 모델에 맞게 카메라를 줌의 다른 유사한 방법입니다.
문제 : 나는 나선에 대한 참조를 가지고 있겠지로 ZoomExtents()를 호출하지 못할 : HelixViewport3D 내 XAML에 선언

당신은 XAML에서 이름을 지정하여 C# 코드에서 Helixviewport에 대한 참조를 만들 수 있습니다

답변

0

난 그냥 내 ScatterPlotVisual3D 이벤트를 추가 HelixViewport3D에 대한 액세스 권한을 가지고 있으며, 그것을() ZoomExtents를 호출 뷰의 민간 기능에 XAML에서이 이벤트를 할당. 이제 내 데이터를로드 할 때 내 이벤트에 전화합니다.

1

:

<helix:HelixViewport3D Name="NameYouChoose" 
         ZoomExtentsWhenLoaded="True" 
         ShowCoordinateSystem="True" 
         IsMoveEnabled="False" 
         Margin="5,5,5,0"> 

그리고 나서 C# 코드에서 자식이 업데이트 된 후 다음을 호출하기 만하면됩니다.

NameYouChoose.ZoomExtents()