Viewport3D ModelVisuals3D not visible when inside Canvas

北城余情 提交于 2019-12-02 07:43:27

I think the ViewPort3D will end up in the upper left corner of the Canvas with a Width and Height of 0 since Canvas never stretches its Children. Try to add Canvas.Left and Canvas.Top at the positioning of your choise and then add Width and Height for your Viewport3D. If you want your Viewport3D to always fill the available space then Canvas is the wrong way to go.

<Canvas Width="900" Height="524">
    <Viewport3D Canvas.Left="100"
                Canvas.Top="100"
                Width="200"
                Height="200"
                Name="mainViewport"
                ClipToBounds="True" 
                IsHitTestVisible="False">
        <Viewport3D.Camera>
            <PerspectiveCamera  
                        FarPlaneDistance="3500" 
                        LookDirection="0,0,1" 
                        UpDirection="0,1,0" 
                        NearPlaneDistance="1"  
                        Position="0,0,0"  
                        FieldOfView="66" />
        </Viewport3D.Camera>
        <ModelVisual3D>
            <ModelVisual3D.Content>
                <AmbientLight Color="White" />
            </ModelVisual3D.Content>
        </ModelVisual3D>
    </Viewport3D>
</Canvas>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!