private async static void AddSlideAnimation(List <FrameworkElement> items) { for (int index = 0; index < items.Count; index++) { var lbi = items[index]; await Window.Current.Dispatcher.RunAsync(CoreDispatcherPriority.High, () => { var animationTargets = lbi.Descendants() .Where(p => ListAnimationsHelper.GetAnimationLevel(p) > -1); foreach (FrameworkElement target in animationTargets) { GetSlideAnimation(target, fromRight).Begin(); } }); } ; }
private static Storyboard GetSlideAnimation(FrameworkElement element, bool fromRight) { double from = fromRight ? 80 : -80; Storyboard sb; double delay = (ListAnimationsHelper.GetAnimationLevel(element)) * 0.1 + 0.1; TranslateTransform trans = new TranslateTransform() { X = from }; element.RenderTransform = trans; sb = new Storyboard(); sb.BeginTime = TimeSpan.FromSeconds(delay); sb.Children.Add(CreateAnimation(from, 0, 0.8, "X", trans)); return(sb); }