此Freezable无法冻结。在wpf Viewport2DVisual3D Visual中

时间:2018-10-15 17:52:52

标签: c# wpf

我正在使用Viewport2DVisual3D。我想显示包含按钮,图像等内容的网格表。用户想要在网格中单击按钮以触发一些事件。现在,用户可以查看并旋转网格使用ScrollBar。但是当用户将鼠标悬停在网格上时,它会显示错误,例如.freezable无法冻结,我无法在我的代码中找到此错误的原因。请帮我。我的Xamal代码如下:< / p>

<Page x:Class="Viewport2DVisual3D.Page4"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d" 
    d:DesignHeight="300" d:DesignWidth="300"
    Title="Page4">

<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="20"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>

<ScrollBar Name="vscroll" 
Grid.Row="0" Grid.Column="1"
Orientation="Vertical"  
Minimum="0" Maximum="360" 
LargeChange="10" SmallChange="1" Value="200" />

<ScrollBar Name="hscroll" 
Grid.Row="1" Grid.Column="0"
Orientation="Horizontal" 
Minimum="0" Maximum="360" 
LargeChange="10" SmallChange="1" Value="0" />

<Viewport3D Margin="4,4,4,4" Grid.Row="0" Grid.Column="0">
<Viewport3D.Camera>
<PerspectiveCamera 
Position = "1.5, 2, 3"
LookDirection = "-1.5, -2, -3"
UpDirection = "0, 1, 0"
FieldOfView = "60">
<PerspectiveCamera.Transform>
<Transform3DGroup>
    <RotateTransform3D>
        <RotateTransform3D.Rotation>
            <AxisAngleRotation3D
Axis="0 1 0" 
Angle="{Binding ElementName=hscroll, Path=Value}" />
        </RotateTransform3D.Rotation>
    </RotateTransform3D>
    <RotateTransform3D>
        <RotateTransform3D.Rotation>
            <AxisAngleRotation3D
Axis="1 0 0" 
Angle="{Binding ElementName=vscroll, Path=Value}" />
        </RotateTransform3D.Rotation>
    </RotateTransform3D>
</Transform3DGroup>
</PerspectiveCamera.Transform>
</PerspectiveCamera>
</Viewport3D.Camera>
<ModelVisual3D>
<ModelVisual3D.Content>
<DirectionalLight Color="White" Direction="0,0,3"/>
</ModelVisual3D.Content>
</ModelVisual3D>
<Viewport2DVisual3D >
<Viewport2DVisual3D.Geometry>

<MeshGeometry3D TriangleIndices="0,1,2 2,3,0 4,5,6 6,7,4 8,9,10 10,11,8 12,13,14 14,15,12 16,17,18 18,19,16 20,21,22 22,23,20"
Positions="-0.755,-1,-0.03125 -0.755,1,-0.03125 0.755,1,-0.03125 0.755,-1,-0.03125 -0.755,-1,-0.0001 0.755,-1,-0.0001 0.755,1,-0.0001 -0.755,1,-0.0001 -0.755,-1,-0.03125 0.755,-1,-0.03125 0.755,-1,-0.0001 -0.755,-1,-0.0001 0.755,-1,-0.03125 0.755,1,-0.03125 0.755,1,0 0.755,-1,0 0.755,1,-0.03125 -0.755,1,-0.03125 -0.755,1,-0.0001 0.755,1,-0.0001 -0.755,1,-0.03125 -0.755,-1,-0.03125 -0.755,-1,-0.0001 -0.755,1,-0.0001"
TextureCoordinates="1,1 1,0 0,0 0,1 0,0 0,0 0,0 1,0 0,0 0,0 1,1 0,0 1,0 1,1 0,1 0,1 0,0 0,1 0,0 1,0 0,1 1,1 1,0 0,0" />


</Viewport2DVisual3D.Geometry>

<Viewport2DVisual3D.Material>

<DiffuseMaterial Viewport2DVisual3D.IsVisualHostMaterial="True"/>

</Viewport2DVisual3D.Material>
<Viewport2DVisual3D.Visual >
<Grid Width="500" Height="500" Background="Wheat" Name="my_grid"    >

<Grid.ColumnDefinitions>

    <ColumnDefinition Width="100" />
    <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
    <RowDefinition Height="100" />
    <RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Column="0" Grid.Row ="0" Background="GreenYellow" >
</StackPanel>

<Button Grid.Column="0" Grid.Row ="1"  Content="Button"  Width="Auto"  Height="Auto"   Click="Button_Click" Padding="0" />

</Grid>

</Viewport2DVisual3D.Visual>

</Viewport2DVisual3D>

</Viewport3D>


</Grid>
</Page>

0 个答案:

没有答案