绑定时如何在xaml中进行计算? [英] How to do calculation in xaml while binding?

查看:20
本文介绍了绑定时如何在xaml中进行计算?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以将标签绑定到滑块,如下所示:

I can bind a label to a slider as shown below:

<Label Name="lblTest" Content="{Binding ElementName=slider1, Path=Value}"/>

如何将另一个标签绑定到同一个滑块,其显示值为滑块值的 30%?如何在 xaml 中而不是在我的代码中进行计算?谢谢.

How do I bind another label to the same slider with display value of, say, 30% of the value of slider? How do I do the calculation in xaml and not in my code? Thanks.

推荐答案

您不能在 XAML 中进行计算,但是您可以应用一些 转换器 为您完成.

You cannot do the calculation in XAML, you could however apply some converter which does it for you.

这个问题可能是相关的:如何更改绑定值、反转它、乘以、减去或添加?

This question might be relevant: How do you change a bound value, reverse it, multiply it, subtract from it or add to it?

这篇关于绑定时如何在xaml中进行计算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆