From 71a234db9b8d01a78cf0da1f7cd758de3f18b84d Mon Sep 17 00:00:00 2001 From: Max Katz Date: Fri, 12 Jun 2020 04:46:10 -0400 Subject: [PATCH] Update MarginMultiplierConverter to support Thickness input --- .../Converters/MarginMultiplierConverter.cs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs b/src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs index 54bd6bcf39..9f3a6da9da 100644 --- a/src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs +++ b/src/Avalonia.Controls/Converters/MarginMultiplierConverter.cs @@ -18,10 +18,24 @@ namespace Avalonia.Controls.Converters public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { - if (!(value is int depth)) - return new Thickness(0); - - return new Thickness(Left ? Indent * depth : 0, Top ? Indent * depth : 0, Right ? Indent * depth : 0, Bottom ? Indent * depth : 0); + if (value is int scalarDepth) + { + return new Thickness( + Left ? Indent * scalarDepth : 0, + Top ? Indent * scalarDepth : 0, + Right ? Indent * scalarDepth : 0, + Bottom ? Indent * scalarDepth : 0); + } + else if (value is Thickness thinknessDepth) + { + return new Thickness( + Left ? Indent * thinknessDepth.Left : 0, + Top ? Indent * thinknessDepth.Top : 0, + Right ? Indent * thinknessDepth.Right : 0, + Bottom ? Indent * thinknessDepth.Bottom : 0); + } + return new Thickness(0); + } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)