我有一个具有主窗口的 WPF 应用程序。在那我有一个框架,框架内容是一个页面。
现在页面中有 4 个 viewport3D,其中包含 Viewport2DVisual3D 并且我有图像元素。
问题:在某些 PC 上,我的应用程序运行良好,但在某些 PC 上,我的应用程序不渲染 viewport3d 或不渲染框架。不知道,但它在主窗口中没有显示任何内容。
该问题发生在 Acer 笔记本电脑型号上。
渲染:
未渲染:
编辑:当我将框架放在网格中时,再次出现此问题。(我在一个框架中显示此页面,该框架是我窗口的主要内容:当我将框架放置在网格中时,它没有显示对象)似乎这发生在具有共享图形的笔记本电脑上
编辑2:
<Page x:Class="MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Loaded="Page_Loaded_1"
x:Name="myMainPage" FlowDirection="RightToLeft" >
<Page.Resources>
<Style TargetType="ContentControl" x:Key="MenuItemsStyle">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Viewport3D VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ClipToBounds="False">
<Viewport3D.Camera>
<PerspectiveCamera x:Name="myCam" FieldOfView="90" Position="{Binding ElementName=myMainWindow, Path=CameraHeight}" NearPlaneDistance="1" FarPlaneDistance="10"/>
</Viewport3D.Camera>
<ModelVisual3D>
<ModelVisual3D.Content>
<Model3DGroup>
<DirectionalLight Color="#FFFFFFFF" Direction="0,0,-1"/>
</Model3DGroup>
</ModelVisual3D.Content>
</ModelVisual3D>
<Viewport2DVisual3D x:Name="V2d3d">
<Viewport2DVisual3D.Transform>
<Transform3DGroup>
<RotateTransform3D >
<RotateTransform3D.Rotation>
<AxisAngleRotation3D Axis="0,1,0" Angle="0" x:Name="aar3D"/>
</RotateTransform3D.Rotation>
</RotateTransform3D>
</Transform3DGroup>
</Viewport2DVisual3D.Transform>
<Viewport2DVisual3D.Material>
<DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True" Brush="White"/>
</Viewport2DVisual3D.Material>
<Viewport2DVisual3D.Geometry>
<MeshGeometry3D Positions="{Binding ElementName=myMainWindow, Path=MeshPosions}"
TextureCoordinates="0,0 0,1 1,1 1,0" TriangleIndices="0 1 2 0 2 3"/>
</Viewport2DVisual3D.Geometry>
<Border Name="mainBorder" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
<Border.Style>
<Style TargetType="Border">
<Setter Property="BorderThickness" Value="1.2"/>
<Setter Property="Background" >
<Setter.Value>
<SolidColorBrush Color="Transparent"/>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" >
<Setter.Value>
<SolidColorBrush Color="Transparent"/>
</Setter.Value>
</Setter>
</Style>
</Border.Style>
<ContentPresenter VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
Content="{TemplateBinding ContentControl.Content}">
<ContentPresenter.Triggers>
<EventTrigger RoutedEvent="ContentPresenter.MouseLeftButtonDown">
// Axis Animation
</EventTrigger>
</ContentPresenter.Triggers>
</ContentPresenter>
</Border>
</Viewport2DVisual3D>
</Viewport3D>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<EventTrigger RoutedEvent="ContentControl.MouseLeftButtonDown" >
//Axis Animation
</EventTrigger>
<EventTrigger RoutedEvent="ContentControl.MouseEnter">
//ScaleAnimation
</EventTrigger>
<EventTrigger RoutedEvent="ContentControl.MouseLeave">
//ScaleAnimation
</EventTrigger>
</Style.Triggers>
</Style>
</Page.Resources>
<Page.Triggers>
<EventTrigger RoutedEvent="Loaded">
//Load Object Scale And Fade In
</EventTrigger>
</Page.Triggers>
<Grid Name="MainGrid">
<Canvas Name="MainCanvas" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" FlowDirection="LeftToRight">
<ContentControl Opacity="0" Name="MenuItem1" Style="{StaticResource MenuItemsStyle}"
MouseDown="MenuItem1_MouseDown" Panel.ZIndex="1" >
<Image Source="/IsargaranProject;component/Images/isargari.jpg"/>
<ContentControl.RenderTransform>
<ScaleTransform ScaleX="0.7" ScaleY="0.7" x:Name="MenuItem1ST"/>
</ContentControl.RenderTransform>
</ContentControl>
</Canvas>
</Grid>
</Page>