From 79b9e9d33d7cacf3edd85f9ecd41e73a2a5767eb Mon Sep 17 00:00:00 2001 From: ClemensFischer Date: Tue, 19 Aug 2025 23:28:22 +0200 Subject: [PATCH] Update MapImageLayer.cs --- MapControl/Shared/MapImageLayer.cs | 35 ++++++++++++++---------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/MapControl/Shared/MapImageLayer.cs b/MapControl/Shared/MapImageLayer.cs index 2e246038..6e536d1b 100644 --- a/MapControl/Shared/MapImageLayer.cs +++ b/MapControl/Shared/MapImageLayer.cs @@ -193,7 +193,7 @@ namespace MapControl cancellationTokenSource = null; - if (image != null) + if (image != null && Children.Count >= 2) { SwapImages(image, boundingBox); } @@ -211,25 +211,22 @@ namespace MapControl private void SwapImages(ImageSource image, BoundingBox boundingBox) { - if (Children.Count >= 2) + var topImage = (Image)Children[0]; + + Children.RemoveAt(0); + Children.Insert(1, topImage); + + topImage.Source = image; + SetBoundingBox(topImage, boundingBox); + + if (MapBase.ImageFadeDuration > TimeSpan.Zero) { - var topImage = (Image)Children[0]; - - Children.RemoveAt(0); - Children.Insert(1, topImage); - - topImage.Source = image; - SetBoundingBox(topImage, boundingBox); - - if (MapBase.ImageFadeDuration > TimeSpan.Zero) - { - FadeOver(); - } - else - { - topImage.Opacity = 1d; - Children[0].Opacity = 0d; - } + FadeOver(); + } + else + { + topImage.Opacity = 1d; + Children[0].Opacity = 0d; } } }