我正在使用 Visual Studio 2013 express 构建一个 Windows 8 商店应用程序,并在 Xaml/c# 中进行编码。
当我水平滚动或只是将手指放在屏幕上时,我的动画会泄漏。泄漏是指闪烁的三角形随机出现在执行动画的网格之外。
我在滚动查看器中尝试了各种设置,但没有任何运气。当我删除滚动查看器时,动画按预期执行,因此问题似乎在于滚动查看器可能重绘页面上的元素。
下面是一个显示问题的测试应用程序
主页.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();
};
}
}
提前致谢