I am having problem in displaying th Image in viewport3d of wpf.
<Grid>
<Image Source="G:\Demo\virtualization\virtualization\2.jpg"/>
<Viewport3D Name="mainViewport" ClipToBounds="True" HorizontalAlignment="Stretch" Height="300">
<Viewport3D.Camera>
<PerspectiveCamera
LookDirection="0,0,-20"
UpDirec开发者_如何学编程tion="0,1,0"
Position="-40,40,40"
/>
</Viewport3D.Camera>
<Viewport2DVisual3D>
<Image Source="G:\Demo\virtualization\virtualization\img3.bmp"/>
</Viewport2DVisual3D>
</Viewport3D>
</Grid>
Above is the code I am using. The first image that is behind the viewport3d is displayed but the image which is inside the viewport3d is not displayed.
Where I am doing wrong?
Please help!
Thanks
You need a material. See if inserting this just above the image tag helps:
<Viewport2DVisual3D.Material>
<DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" Brush="White"/>
</Viewport2DVisual3D.Material>
Edit: taken from MSDN documentation. Can't try it right now, but you might also need other tags as specified in the example here: http://msdn.microsoft.com/de-de/library/system.windows.media.media3d.viewport2dvisual3d.aspx
精彩评论