Silverlight是否支持StringFormat绑定? [英] Does Silverlight support StringFormat in binding?
问题描述
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屋!