You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WPF中C#创建Perspective Camera应用到Viewport3D无效问题

WPF中C#代码创建PerspectiveCamera无法渲染3D场景问题

我尝试使用C#创建新的PerspectiveCamera并将其应用到XAML中的Viewport3D组件,但直接在XAML中编写对应代码时可正常显示3D场景,使用C#实现相同逻辑却无法正常渲染,仅呈现空白屏幕。我采用了微软官方的3D场景创建示例代码,其中XAML版本运行正常,但C#版本依旧无效。

相关代码如下:

XAML版本代码

<Viewport3D Name="SceneViewViewport" Width="954" Height="659">...</Viewport3D>

C#初始化代码

viewport = (Viewport3D)FindName("SceneViewViewport");
SceneViewWidth = (float)viewport.Width;
SceneViewHeight = (float)viewport.Height;
Setup();

Setup方法代码

void Setup() {... }

内容的提问来源于stack exchange,提问作者kibrjr BC

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 06:40:29