我做一个简单 的图片浏览控件 ,一个canavs当容器,里面包含子canavs,子canavs里有很多图片,滑动时就控制子canavs坐标,当我用storyboard时候且图片超过4张时,自动滑动时图片不见了,滑动停止后就出来了。布局代码如下:
<Canvas x:Name="LayoutRoot" ManipulationDelta="LayoutRoot_ManipulationDelta" ManipulationStarted="LayoutRoot_ManipulationStarted" ManipulationCompleted="LayoutRoot_ManipulationCompleted"> <Canvas x:Name="canImages" Canvas.ZIndex="0" Background="#FF7CDEF1" Loaded="canImages_Loaded" /> <StackPanel x:Name="spEllipse" Canvas.ZIndex="1" Height="20" Width="480" Orientation="Horizontal" Background="#FF8F9295" Opacity="0.5" Margin="0"> </StackPanel> </Canvas>
滑动代码
Storyboard board = new Storyboard(); board.Completed += new EventHandler(ShowCompleted); DoubleAnimation da = new DoubleAnimation(); da.From = sx; da.To = endX; da.Duration = new Duration(TimeSpan.FromMilliseconds(500)); Storyboard.SetTarget(da, canImages); Storyboard.SetTargetProperty(da, new PropertyPath(Canvas.LeftProperty)); board.Children.Add(da); board.Begin();
查了好久了,我这里有源码,有时间的童鞋可以加q 247209716,我发源码,感激不敬