To animate a clip must animate the clip property that is either a Path, a Geometry. Animating a Path quickly became archaic ... the choice will very quickly on the animation of geometric shapes. However, the animations have their limits too. In silverlight there are three types of animations: DoubleAnimation, PointAnimation, ColorAnimation you will not have the possibility (unlike WPF example) to animate rectangleGeometry. It simply means that to achieve a Collapse / Expand panel using LineGeometry and PointAnimation be prescribed.
Code:
1: <Canvas Width = "326" Height = "192" Canvas. Left = "56296" Canvas. Top = "75">
2: <Canvas.Clip>
3: <PathGeometry>
4: <PathFigure>
5: <LineSegment x: Name = "rctLineSeg1" Point = "0.0" />
6: <LineSegment x: Name = "rctLineSeg2" Point = "326.0" />
7: <LineSegment x: Name = "rctLineSeg3" Point = "326.192" />
8: <LineSegment x: Name = "rctLineSeg4" Point = "0.192" />
9: </ PathFigure>
10: </ PathGeometry>
11: </ Canvas.Clip>
12: <TextBlock ... />
13: </ Canvas>
The subtlety is to animate LineSegment via a "Storyboard> when MouseLeftButtonUp.
Code:
Closing Panel:
1: <PointAnimationUsingKeyFrames BeginTime = "00:00:00" Storyboard. TargetName = "rctLineSeg3" Storyboard. TargetProperty = "Item">
2: <SplinePointKeyFrame keySplines = "0,0.4,0.6,1" keytimer = "00:00:00.45" Value = "326.0" />
3: </ PointAnimationUsingKeyFrames>
4: <PointAnimationUsingKeyFrames BeginTime = "00:00:00" Storyboard. TargetName = "rctLineSeg4" Storyboard. TargetProperty = "Item">
5: <SplinePointKeyFrame keySplines = "0,0.4,0.6,1" keytimer = "00:00:00.45" Value = "0.0" />
6: </ PointAnimationUsingKeyFrames>
Opening Panel:
1: <= PointAnimationUsingKeyFrames BeginTime "00:00:00" Storyboard. TargetName = "rctLineSeg3" Storyboard. TargetProperty = "Item">
2: <SplinePointKeyFrame keySplines = "0,0.4,0.6,1" keytimer = "00:00:00.45" Value = "326.192" />
3: </ PointAnimationUsingKeyFrames>
4: <PointAnimationUsingKeyFrames BeginTime = "00:00:00" Storyboard. TargetName = "rctLineSeg4" Storyboard. TargetProperty = "Item">
5: <SplinePointKeyFrame keySplines = "0,0.4,0.6,1" keytimer = "00:00:00.45" Value = "0.192" />
6: </ PointAnimationUsingKeyFrames>
This task, which at first seems very simple is far more complicated than it seems. We can therefore hope that the version of Silverlight 2 will bring some novelties in the field of clipping and will enrich the animation engine already present in the plugin 1.0.
Bookmarks