问题描述
能否请您展示如何设置和保存 viewport3D 的背景颜色.每当我保存没有背景是唯一可见的模型时,我尝试了网格,但是网格中的所有内容?有什么帮助吗?
Can you please show how to set and save the background color of the viewport3D. Whenever I save no background is visible only model, I tried the grid but that gets everything in the grid? Any help will do?
推荐答案
Viewport3D 没有 Background 属性,因此您需要在它后面添加一些东西.
Viewport3D doesn't have a Background property so you need something behind it.
您使用 Grid 的方法是正确的,您可能希望使用 Border 来执行使用一个孩子.
your approach using a Grid is right, you might want to use a Border to enforce the use of a single child.
<Border Background="Green">
<Viewport3D Width="640.0" Height="480.0" >
<ModelVisual3D/>
</Viewport3D>
</Border>
我假设您正在使用 XamlWriter, XamlReader .只需保存边框而不是 Viewport3D,边框内的所有内容也会被保存.
I assume you are using XamlWriter, XamlReader . Just save the border instead of the Viewport3D and everything inside the border will be saved as well.
这篇关于视口 3D WPF C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!