我在窗口上有一些3D元素,我想在某些时候删除一切,并有一个新的开始,我该怎么做? 我在XAML上有这个:
<tools:TrackballDecorator>
<Viewport3D x:Name="_Main3D"
ClipToBounds="False"
Camera="{StaticResource Other3D_MainCamera}">
<!-- ModelVisual3D containing the lights -->
<StaticResource ResourceKey="Other3D_Lights" />
<!--
Clickable 3D models (ModelUIElement3D): Cover, spine and edges
They will work as if they were one object, so I'll use only one ModelUIElement3D to hold them and wire up their events.
-->
<ModelUIElement3D MouseDown="Cover_MouseDown" x:Name="Book">
<ModelUIElement3D.Model>
<Model3DGroup>
<GeometryModel3D x:Name="_FrontCover"
Geometry="{StaticResource MeshGeometry3D_Cover}"
Material="{StaticResource Material_FrontCover}"
Transform="{StaticResource Transform3D_FrontCover}" />
<GeometryModel3D x:Name="_BackCover"
Geometry="{StaticResource MeshGeometry3D_Cover}"
Material="{StaticResource Material_Cover}"
Transform="{StaticResource Transform3D_BackCover}" />
<GeometryModel3D x:Name="_SpineCover"
Geometry="{StaticResource MeshGeometry3D_Cover}"
Material="{StaticResource Material_Cover}"
Transform="{StaticResource Transform3D_SpineCover}" />
<GeometryModel3D x:Name="_LeftEdge"
Geometry="{StaticResource MeshGeometry3D_Edge}"
Material="{StaticResource Material_Edge}"
Transform="{StaticResource Transform3D_Left}" />
<GeometryModel3D x:Name="_RightEdge"
Geometry="{StaticResource MeshGeometry3D_Edge}"
Material="{StaticResource Material_Edge}"
Transform="{StaticResource Transform3D_Right}" />
</Model3DGroup>
</ModelUIElement3D.Model>
</ModelUIElement3D>
<!-- Interactive 3D models: Pages -->
<Viewport2DVisual3D x:Name="_LeftPage"
Geometry="{StaticResource MeshGeometry3D_Plane}"
Transform="{StaticResource Transform3D_Left}">
<Viewport2DVisual3D.Material>
<DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" />
</Viewport2DVisual3D.Material>
<Viewport2DVisual3D.Visual>
<Image Source="C:\Users\Public\Pictures\Sample Pictures\Chrysanthemum.jpg" Stretch="None" HorizontalAlignment="Center" VerticalAlignment="Center" />
</Viewport2DVisual3D.Visual>
</Viewport2DVisual3D>
<Viewport2DVisual3D x:Name="_RightPage"
Geometry="{StaticResource MeshGeometry3D_Plane}"
Transform="{StaticResource Transform3D_Right}">
<Viewport2DVisual3D.Material>
<DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" />
</Viewport2DVisual3D.Material>
<Viewport2DVisual3D.Visual>
<!--
<TextBox Style="{StaticResource Control_PagesStyle}"
Padding="5,30,30,30"
MouseDoubleClick="Page_MouseDoubleClick" />
-->
<!-- The TextBox above was replaced by an InkCanvas -->
<InkCanvas Style="{StaticResource Control_InkCanvasStyle}" PreviewMouseRightButtonDown="InkCanvas_PreviewMouseRightButtonDown"/>
</Viewport2DVisual3D.Visual>
</Viewport2DVisual3D>
</Viewport3D>
</tools:TrackballDecorator>
但是当我尝试做
时_LayoutRoot.Children.Remove()
它不允许它,因为它们不是UIElements。 对此有何帮助?
答案 0 :(得分:0)
解决, 用过的 : _LayoutRoot.Children.Clear();
它有效。
Clear()从网格中删除所有元素, 并使它们为垃圾收集做好准备。 希望这有助于某人。