我正在使用Visual Studio 2013 express构建一个Windows 8商店应用程序,并使用Xaml / c#进行编码。
当我水平滚动或只是将手指放在屏幕上时,我的动画会泄漏。泄漏我的意思是闪烁的三角形随机出现在执行动画的网格之外。
我已经在滚动查看器中尝试了各种设置而没有任何运气。当我删除scrollviewer时,动画按预期执行,所以看起来问题在于scrollviewer可能重绘页面上的元素。
以下是显示问题的测试应用
MainPage.xaml中
<Page.Resources>
<Storyboard x:Name="Storyboard1" AutoReverse="True" RepeatBehavior="Forever">
<DoubleAnimation Duration="0:0:0.8" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="Border" d:IsOptimized="True"/>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="Border1">
<EasingDoubleKeyFrame KeyTime="0:0:0.8" Value="-90"/>
<EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="Border2">
<EasingDoubleKeyFrame KeyTime="0:0:1.6" Value="-90"/>
<EasingDoubleKeyFrame KeyTime="0:0:2.5" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationY)" Storyboard.TargetName="Border3">
<EasingDoubleKeyFrame KeyTime="0:0:2.5" Value="90"/>
<EasingDoubleKeyFrame KeyTime="0:0:3.3" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Page.Resources>
<ScrollViewer x:Name="MainScroll" ScrollViewer.ZoomMode="Disabled" ScrollViewer.VerticalScrollBarVisibility="Disabled"
ScrollViewer.HorizontalScrollBarVisibility="Hidden" ScrollViewer.HorizontalScrollMode="Enabled"
ScrollViewer.VerticalScrollMode="Disabled">
<StackPanel Orientation="Horizontal">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Width="500" Height="500">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="1*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*" />
<RowDefinition Height="1*" />
</Grid.RowDefinitions>
<Grid Grid.RowSpan="2" Grid.ColumnSpan="2" Background="Red"/>
<Border x:Name="Border" Background="Purple" >
<Border.Projection>
<PlaneProjection RotationY="90"/>
</Border.Projection>
</Border>
<Border x:Name="Border1" Background="Purple" Grid.Column="1" >
<Border.Projection>
<PlaneProjection RotationY="-90"/>
</Border.Projection>
</Border>
<Border x:Name="Border3" Background="Purple" Grid.Row="1" >
<Border.Projection>
<PlaneProjection RotationY="90"/>
</Border.Projection>
</Border>
<Border x:Name="Border2" Background="Purple" Grid.Row="1" Grid.Column="1" >
<Border.Projection>
<PlaneProjection RotationX="-90"/>
</Border.Projection>
</Border>
</Grid>
<Grid Width="1000" Background="Blue" Height="300" Margin="50"/>
</StackPanel>
</ScrollViewer>
MainPage.xaml.cs中
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
Loaded += (s, args) =>
{
this.Storyboard1.Begin();
};
}
}
提前致谢
答案 0 :(得分:0)
在Android上编写OpenGL代码之前我已经看过了。事实证明我的代码中有一个错误。当你犯错误时,OpenGL会提供所有这些令人讨厌的错误,因为它是一个巨大的状态机。对不起,我无法提供更多帮助。但听起来你在某处做错了(我当时)。您是否可以尝试评论问题,直到问题不再发生?也许缩小范围会有所帮助。