private static void ShadowDepthChangedCallback(AvaloniaPropertyChangedEventArgs e) { if (!PleasantSettings.Settings.EnableShadowing) { return; } Border border = e.Sender as Border; BoxShadows?boxShadow = border?.BoxShadow; if (boxShadow == null) { return; } BoxShadows targetBoxShadows = GetShadowDepth((AvaloniaObject)e.Sender).ToBoxShadows(); if (!border.Classes.Contains("notransitions") && boxShadow.Value.Count > 0) { Animation animation = new Animation { Duration = TimeSpan.FromMilliseconds(75), FillMode = FillMode.Both }; animation.Children.Add( new KeyFrame { Cue = Cue.Parse("0%", CultureInfo.CurrentCulture), Setters = { new Setter { Property = Border.BoxShadowProperty, Value = boxShadow } } }); animation.Children.Add( new KeyFrame { Cue = Cue.Parse("100%", CultureInfo.CurrentCulture), Setters = { new Setter { Property = Border.BoxShadowProperty, Value = targetBoxShadows } } }); animation.RunAsync(border, null, default); } else { border.SetValue(Border.BoxShadowProperty, targetBoxShadows); } }