Click here to Skip to main content
15,884,943 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Why am i getting this error? This is code from the microsoft website:
XAML
<GeometryModel3D>
            <GeometryModel3D.Geometry>
                <MeshGeometry3D 
              Positions="-1 -1 0  1 -1 0  -1 1 0  1 1 0"
              Normals="0 0 1  0 0 1  0 0 1  0 0 1"
              TextureCoordinates="0 1  1 1  0 0  1 0   "
              TriangleIndices="0 1 2  1 3 2" />
            </GeometryModel3D.Geometry>
            <GeometryModel3D.Material>
                <DiffuseMaterial>
                    <DiffuseMaterial.Brush>
                        <SolidColorBrush Color="Cyan" Opacity="0.3"/>
                    </DiffuseMaterial.Brush>
                </DiffuseMaterial>
            </GeometryModel3D.Material>
            <!-- Translate the plane. -->
            <GeometryModel3D.Transform>
                <TranslateTransform3D
            OffsetX="2" OffsetY="0" OffsetZ="-1"   >
                </TranslateTransform3D>
            </GeometryModel3D.Transform>
        </GeometryModel3D>


What I have tried:

well some random other things like adding some dlls and none worked.
Posted
Updated 14-Jun-21 3:55am

1 solution

Because you're adding the GeometryModel3D element at the wrong place in your markup.

We can't tell you precisely where, because you forgot to include the parent element. According to the documentation, it looks like it needs to be inside a ModelVisual3D/ModelVisual3D.Content element:
How to: Create a 3D Scene - WPF .NET Framework | Microsoft Docs[^]
XAML
<ModelVisual3D>
    <ModelVisual3D.Content>
        <GeometryModel3D>
 
Share this answer
 
Comments
A-Games 14-Jun-21 11:39am    
Thanks- This was very helpful.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900