blend 3 创建silverlight动画问题
blend 3 创建silverlight动画,在对象时间轴里有效果,但运行网页无法显示动画效果。是不是要加什么代码。
我就是在silverlight仿wpf一样做了一个移动动画,在对象时间轴里有动画显示,但按F5网页就没有动画过程,请问什么原因。,
[解决办法]
c# 里加一个 (动画面板名称).begin
[解决办法]
如果你没有事件触发,动画不会自动执行,后台需要调用storyboard.begin方法来运行动画。
或者添加trigger来运行。
可以参考以下代码:
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:im="clr-namespace:Microsoft.Expression.Interactivity.Media;assembly=Microsoft.Expression.Interactions" x:Class="StoryBoardDemo.MainPage" Width="640" Height="480"> <UserControl.Resources> <Storyboard x:Name="Storyboard1" AutoReverse="True" RepeatBehavior="Forever"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)"> <SplineDoubleKeyFrame KeyTime="00:00:00" Value="357"/> <EasingDoubleKeyFrame KeyTime="00:00:02" Value="-1.5"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)"> <SplineDoubleKeyFrame KeyTime="00:00:00" Value="51"/> <SplineDoubleKeyFrame KeyTime="00:00:02" Value="63" KeySpline="0.680000007152557,1,0.0399999991059303,0.0199999995529652"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </UserControl.Resources> <Grid x:Name="LayoutRoot" Background="White"> <i:Interaction.Triggers> <i:EventTrigger EventName="Loaded"> <im:ControlStoryboardAction Storyboard="{StaticResource Storyboard1}"/> </i:EventTrigger> </i:Interaction.Triggers> <Image x:Name="image" Height="78" HorizontalAlignment="Right" Margin="0,53,94,0" VerticalAlignment="Top" Width="80" RenderTransformOrigin="0.5,0.5" Source="sl.jpg"> <Image.RenderTransform> <TransformGroup> <ScaleTransform/> <SkewTransform/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </Image.RenderTransform> </Image> <Button Margin="169,186,180,202" Style="{StaticResource ButtonStyle2}" Content="Button"/> </Grid></UserControl>