Is is possible to do basic mathematical operations like addition, division etc. in XAML?
For example, I want to set the height of a button to {Binding ElementName=MW,Path=Height}/2
.
Take a look at Arithmetic operations in Xaml for simple operations
and
for more complex evaluation look at Impossible WPF Part 2: Binding Expressions
To answer your question: No, it is not possible.
My advice would be to create a value converter and apply them using bindings, for any mathematical operations you want to perform. The view is definitely not the place to perform mathematical operations, you want to have that concern separated and isolated in a different class, so that it is easier to debug and maintain.
Not possible without using a converter or a view model that does the conversion for you. For a generic converter, see ExpressionConverter
in my WPF Converters project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With