【问题标题】:StringFormat in wp7?wp7中的字符串格式?
【发布时间】:2011-03-06 19:22:32
【问题描述】:

有没有办法在一个 TextBlock 中结合静态文本和绑定?因为 StringFormat 在 windows phone 7 中不起作用。 我试试

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

但不工作....

谢谢

【问题讨论】:

标签: silverlight windows-phone-7


【解决方案1】:

实际上,如果您可以更改视图模型并在属性中进行格式化,您将获得比依赖 IValueConverter 更好的性能。

我使用这些模式仍然给我属性更改通知

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

【讨论】:

  • 这是真的;尽管我的回答是,这也是我一直在努力的方向。也更容易调试。
  • 我同意@jeff 的观点。更清洁的解决方案。 +1
【解决方案2】:

WP7 使用Silverlight 3。所以,你不会得到StringFormat。请改用IValueConverter

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-02
    • 2013-05-02
    • 2015-05-08
    • 1970-01-01
    相关资源
    最近更新 更多