简体   繁体   English

如何在XAML中使用数学运算

[英]How use math operations in XAML

我想在XAML代码中使用数学运算,但我不知道怎么做?

You mean you want to perform arithmetic operations in xaml? 你的意思是你想在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"/>

Checkout this : 结帐:

http://blogs.msdn.com/b/llobo/archive/2006/11/13/arithmetic-operations-in-xaml.aspx http://blogs.msdn.com/b/llobo/archive/2006/11/13/arithmetic-operations-in-xaml.aspx

One of the common hurdles (if you may call that) that I face while writing some xaml is performing simple arithmetic operations while binding. 在编写一些xaml时我面临的一个常见障碍(如果你可以称之为)是在绑定时执行简单的算术运算。 hmm… I am sure many have faced the same… The solution is writing an IValueConverter and you are set… For simple math like [ActualHeight+10] we can readily use the ArithmeticConverter code... 嗯...我相信很多人都面临同样的问题......解决方案是编写IValueConverter并设置...对于像[ActualHeight + 10]这样的简单数学,我们可以很容易地使用ArithmeticConverter代码......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM