StringFormat in wp7?

删除回忆录丶 提交于 2019-12-19 20:37:00

问题


Is there a way to combine static text AND binding in one TextBlock? Because StringFormat don't work in windows phone 7. I try

<TextBlock Text="{Binding strAudioArtistName, StringFormat=StaticText: {0}}"/>

but don't work....

Thank


回答1:


Actually if you can change your viewmodel and do the formatting in a property you will get much better performance than relying on an IValueConverter.

I use a pattern along these lines to still give me property change notifications

string _value;
public string Value { get { return _value; } set { _value = value; NotifyPropertyChanged("Value"); NotifyPropertyChanged("ValueFormatted"); } }
public string ValueFormatted { get { return "Static Text: " + _value; } }



回答2:


WP7 uses Silverlight 3. So, you don't get StringFormat. Use IValueConverter instead.



来源:https://stackoverflow.com/questions/5212811/stringformat-in-wp7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!