C# 代码
DoubleAnimation daanimation = new DoubleAnimation();//创建动画
daanimation.From = 0;//动画开始值
daanimation.To = 1;//动画结束值
daanimation.Duration = TimeSpan.FromSeconds(40);//动画持续时间
Storyboard.SetTarget(daanimation, myslider);//指定要执行动画的对象
Storyboard.SetTargetProperty(daanimation, new PropertyPath(Slider.ValueProperty));//指定依赖项的路径
Storyboard sb = new Storyboard();//创建故事版
sb.Children.Add(daanimation);//将动画版添加到故事版
sb.Begin(myslider,true);//开始执行,(myslider,绑定的数值允许交互更改。默认为false。false的话设置动画倍速不会立即生效)
sb.SetSpeedRatio(myslider, 4);
Xmal 代码
<Slider HorizontalAlignment="Left" Name="myslider" Margin="46,160,0,0" Maximum="1" Width="200" Background="Black" VerticalAlignment="Top"/>
<Button Content="Button" HorizontalAlignment="Left" Margin="127,115,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click_1"/>