Silverlight是否支持StringFormat绑定? [英] Does Silverlight support StringFormat in binding?

查看:166
本文介绍了Silverlight是否支持StringFormat绑定?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道WPF 3.5 SP1在绑定中支持一个 StringFormat ,但是Silverlight会做同样的事情吗?我以为可以,但是如果我能使它工作,那么可以死吧!



这是我的XAML的一个代码片段:

 < TextBlock Text ={Binding StartTime,StringFormat = t}/> 

它编译OK,但是当它访问浏览器时会收到运行时错误...


解决方案

Silverlight 3及更低版本不需要,但您可以使用Value Converter并在绑定中指定ConverterParamenter。您必须通过从IValueConverter派生类创建自己的价值转换器,就像我已经显示这里



Silverlight 4及更高版本与WPF相同的StringFormat绑定属性。


I know that WPF 3.5 SP1 supports a StringFormat in a binding, but can Silverlight do the same? I thought it could, but damned if I can make it work!

Here's a snippet of my XAML:

<TextBlock Text="{Binding StartTime, StringFormat=t}" />

It compiles OK, but I get a runtime error when it gets to the browser...

解决方案

Silverlight 3 and below do not, but you can use a Value Converter and specify the ConverterParamenter in the binding. You'll have to create your own Value Converter by deriving a class from IValueConverter like I've shown here.

Silverlight 4 and later has the same StringFormat binding property as WPF.

这篇关于Silverlight是否支持StringFormat绑定?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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