A XAML Converter that does it all.
$ dotnet add package MathConverterMathConverter allows you to do Math in XAML.
MathConverter is a powerful Binding converter that allows you to specify how to perform conversions directly in XAML, without needing to define a new IValueConverter in C# for every single conversion.
It's as easy as 1-2-3.
1) Install the Nuget package.
2) Add a MathConverter resource.
<Application.Resources>
<math:MathConverter x:Key="Math" />
</Application.Resources>
The math namespace is defined as follows*:
xmlns:math="http://hexinnovation.com/math"
3) Do Math. Now, you can use MathConverter on any Binding. Specify a ConverterParameter to specify the rules of the conversion.
<Border.CornerRadius>
<MultiBinding ConverterParameter="Min(x,y)/2" Converter="{StaticResource Math}">
<Binding Path="ActualHeight" />
<Binding Path="ActualWidth" />
</MultiBinding>
</Border.CornerRadius>
See the GitHub repository for documentation and examples.