这个freezable不能冻结。在WPF中viewport2dvisual3d visual [英] This freezable cannot be frozen. In WPF viewport2dvisual3d visual

查看:133
本文介绍了这个freezable不能冻结。在WPF中viewport2dvisual3d visual的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究Viewport2DVisual3D。我想显示网格表,其中包含按钮,图像等内容。用户想点击网格中的按钮来触发一些事件。现在用户可以查看网格并旋转它使用ScrollBar。但是当用户将鼠标悬停在网格上时,它会显示错误。这个freezable无法冻结,我无法在我的代码中找出原因。请帮助我。我的XAML代码如下:



我尝试过:



I am working on Viewport2DVisual3D .I want to display the grid table with contents like button , image etc.User wants to click on the button in the gird to fire some events.Now User are able to view the grid and rotate it with ScrollBar .But when the user mouse over the grid it shows the error like .This freezable cannot be frozen, I am not able to find out the reason in my code .Please help me. My XAML code is below:

What I have tried:

<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>

推荐答案

这是因为 IFreezable o bject的 CanFreeze 标志是 false 。由于您没有提供真实的信息,这是我能为您做的最好的。
It's because the IFreezable object's CanFreeze flag is false. Since you provided no real info, that's the best I can do for you.


这篇关于这个freezable不能冻结。在WPF中viewport2dvisual3d visual的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆