如何将多个值数据绑定到WP7中的单个TextBlock.Text?

编程入门 行业动态 更新时间:2024-10-04 05:24:49
本文介绍了如何将多个值数据绑定到WP7中的单个TextBlock.Text?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何将两个属性绑定到单个TextBlock.Text(例如,名字和姓氏或当前值和最大值)?

How can I bind 2 properties to a single TextBlock.Text (eg. first name and last name or current value and max value)?

类似于: / p>

something like:

// IValueConverter public object Convert( .... ) { return string.Format("{0} (max: {1})", currentValue, maxValue); }

问题是我希望TextBlock.Text在 currentValue 或 maxValue 已更改。那么如何使用数据绑定来监听来自2个或更多属性的更改?

The problem is I want TextBlock.Text to be updated when currentValue or maxValue has changed. So how can I listen to changes from 2 or more properties using data binding?

有没有另外一种方法比用户使用 IValueConverter ?

Is there another way than usering IValueConverter?

推荐答案

Silverlight 3(在其上构建Windows Phone 7框架)不支持MultiBinding,这是你将用来实现你所需要的。但是,有一个解决方案解决方案,您可以使用在 MultiBinding for Sivlerlight 3 中的描述也可以使用WP7。

Silverlight 3 (on which the Windows Phone 7 framework is built) doesn't support MultiBinding, which is what you would use to achieve what you need. However, there is a workaround solution that you can use described in the post MultiBinding for Sivlerlight 3, which should also work on WP7.

或者,您可以扩展视图模型(或至少是您所暴露的属性),以显示一个聚合值并引发的属性财产变更通知,当更改。

Alternatively, you could extend your view model (or at least the properties that you are exposing) to expose a property that aggregates your values and raises property change notification when either changes.

更多推荐

如何将多个值数据绑定到WP7中的单个TextBlock.Text?

本文发布于:2023-07-09 10:18:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1085596.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:多个   绑定   如何将   数据   Text

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!