Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change ViewPort3D background color in WPF?

i have viewport3d and i want to change its background color.

i am very new to Wpf. i didnt understand what to do from other posts. so i ask here.

i changed brush property for viewport3d but it does nothing

<Window x:Class="W3DTinker.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="800" Width="1200">
<Grid HorizontalAlignment="Left" Height="780" Margin="10,10,0,-21" VerticalAlignment="Top" Width="1180">
    <Viewport3D Grid.Row="0" Grid.Column="0" x:Name="Viewport" Margin="350,10,10,10" OpacityMask="{DynamicResource {x:Static SystemColors.AppWorkspaceBrushKey}}" />
</Grid>

like image 932
M.kazem Akhgary Avatar asked Oct 22 '25 03:10

M.kazem Akhgary


1 Answers

Viewport3D is a control that creates a 3D scene for you to render things into. It does not display anything by itself. If you want a background color behind it, then set the background color on its parent control, which in your case is the Grid that contains it.

like image 90
Xavier Avatar answered Oct 23 '25 18:10

Xavier