Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How use math operations in XAML

Tags:

c#

.net

wpf

I want use math operations in XAML code but I dont know how?

like image 567
Alex Sabaka Avatar asked May 24 '10 12:05

Alex Sabaka


People also ask

Can you do math in XAML?

In other words, it can perform simple calculations directly in XAML, eliminating the necessity to clutter your view model or write one-off value converters.

What is the use of mathematical operations?

The mathematical “operation” refers to calculating a value using operands and a math operator. The symbol of the math operator has predefined rules to be applied to the given operands or numbers.

Can we do mathematical operations on string?

You can use the eval function to evaluate mathematical expressions in strings.


1 Answers

You mean you want to perform arithmetic operations in xaml?

check out this post (it comes with a sample project)

It allows you to specify code like this:

<TextBlock Height="{Binding ElementName=tb1, Path=ActualHeight,
  Converter={StaticResource JScript},
  ConverterParameter=Int32.Parse(values[0])/10 *100-110 }" Background="Red"/>
like image 99
Jowen Avatar answered Oct 03 '22 21:10

Jowen