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)