|
private void GridView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
var imageItem = this.photoGridViewList.SelectedItem as ImageItem;
var viewItem = this.photoGridViewList.ItemContainerGenerator.ContainerFromItem(imageItem) as GridViewItem;
if(viewItem!=null)
{
IEnumerable imageList= viewItem.GetDescendantsOfType();
foreach (var image in imageList)
{
if(image.Name == "TouchAnimation")
{
DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames1 = new DoubleAnimationUsingKeyFrames();
doubleAnimationUsingKeyFrames1.KeyFrames.Add(new EasingDoubleKeyFrame() { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0 });
doubleAnimationUsingKeyFrames1.KeyFrames.Add(new EasingDoubleKeyFrame() { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.4)), Value = 1 });
Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrames1, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
Storyboard.SetTarget(doubleAnimationUsingKeyFrames1, image);
DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames2 = new DoubleAnimationUsingKeyFrames();
doubleAnimationUsingKeyFrames2.KeyFrames.Add(new EasingDoubleKeyFrame() { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 0 });
doubleAnimationUsingKeyFrames2.KeyFrames.Add(new EasingDoubleKeyFrame() { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.4)), Value = 1 });
Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrames2, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
Storyboard.SetTarget(doubleAnimationUsingKeyFrames2, image);
DoubleAnimationUsingKeyFrames doubleAnimationUsingKeyFrames3 = new DoubleAnimationUsingKeyFrames();
doubleAnimationUsingKeyFrames3.KeyFrames.Add(new EasingDoubleKeyFrame() { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0)), Value = 1 });
doubleAnimationUsingKeyFrames3.KeyFrames.Add(new EasingDoubleKeyFrame() { KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromSeconds(0.4)), Value = 0 });
Storyboard.SetTargetProperty(doubleAnimationUsingKeyFrames3, "(UIElement.Opacity)");
Storyboard.SetTarget(doubleAnimationUsingKeyFrames3, image);
Storyboard sb = new Storyboard();
sb.Children.Add(doubleAnimationUsingKeyFrames1);
sb.Children.Add(doubleAnimationUsingKeyFrames2);
sb.Children.Add(doubleAnimationUsingKeyFrames3);
sb.Begin();
break;
}
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
var daX = new DoubleAnimation();
var daY = new DoubleAnimation();
var be = new BounceEase();
be.Bounces = 3;
be.Bounciness = 3;
daY.EasingFunction = be;
daX.To = 300;
daY.To = 300;
var duration = new Duration(TimeSpan.FromSeconds(2));
daX.Duration = duration;
daY.Duration = duration;
Storyboard.SetTargetProperty(daX, "(UIElement.RenderTransform).(CompositeTransform.TranslateX)");
Storyboard.SetTargetProperty(daY, "(UIElement.RenderTransform).(CompositeTransform.TranslateY)");
Storyboard.SetTarget(daX, btnAnimation);
Storyboard.SetTarget(daY, btnAnimation);
var sb = new Storyboard();
sb.Children.Add(daX);
sb.Children.Add(daY);
sb.Begin();
}
|
|
|