private void Flip() { if (containerGrid.Children != null && containerGrid.Children.Count > 0) { var image = containerGrid.Children[rnd.Next(0, containerGrid.Children.Count)] as Image; var uri = ImageSourceMap.Uris[rnd.Next(0, ImageSourceMap.Count)]; var source = ImageSourceMap[uri]; Storyboard.SetTarget(FadeOutAnimation, image); Storyboard.SetTarget(FadeInAnimation, image); Task.Run(() => { SyncContext.Post((o) => FadeOutStoryboard.Begin(), null); Task.Delay(1_500).GetAwaiter().GetResult(); SyncContext.Post((o) => { ImageSourceMap.MinusOneReference(image.Source); image.Source = source; FadeInStoryboard.Begin(); }, null); }); } }
public void SetUris(IEnumerable <Uri> uris) { ImageSourceMap.SetUris(uris); }