silverligth动画,Storyboard的使用问题?
今天想研究一下动画,对一些参数不了解
如下所示,我是想画一个圆,并想让它在加载的时候出现平移效果
前台的一些代码
<Grid.Resources>
<Storyboard x:Name="StoryboardArrowAnimation" BeginTime="0:0:1" >
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="ElectricPath">
<DiscreteDoubleKeyFrame KeyTime="0" Value="320"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0">
<EasingDoubleKeyFrame.EasingFunction>
<CubicEase EasingMode="EaseOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Grid.Resources>
//绘制形状
<Path x:Name="ElectricPath" UseLayoutRounding="False" Width="50" Height="50" Fill="#efeded" Stroke="Black" StrokeThickness="1" RenderTransformOrigin="0.5,0.5" Canvas.Left="360" Canvas.Top="46" Opacity="1">
<Path.Data>
<EllipseGeometry Center="25,25" RadiusX="25" RadiusY="25" />
</Path.Data>
<Path.RenderTransform>
<CompositeTransform></CompositeTransform>
</Path.RenderTransform>
</Path>
后台在加载完成后,StoryboardArrowAnimation.Begin();Storyboard开始动画吧,但是并没有出现效果,请问各位大哥,小弟哪里设置错误了。
[解决办法]
使用blend做
[解决办法]
StoryboardArrowAnimation.Begin();是否写在InitializeComponent();之后?
[解决办法]
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="SilverlightApplication11.MainPage" Width="800" Height="600"> <Grid Background="White"> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="VisualStateGroup"> <VisualState x:Name="VisualState"> <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateX)" Storyboard.TargetName="ellipse"> <EasingDoubleKeyFrame KeyTime="0" Value="-384"/> <EasingDoubleKeyFrame KeyTime="0:0:2" Value="-164"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimation Duration="0" To="10" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="ellipse" d:IsOptimized="True"/> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Ellipse x:Name="ellipse" HorizontalAlignment="Left" Height="100" Margin="279,170,0,0" VerticalAlignment="Top" Width="100" Fill="Black" RenderTransformOrigin="0.5,0.5"> <Ellipse.RenderTransform> <CompositeTransform/> </Ellipse.RenderTransform> </Ellipse> </Grid> </UserControl>