【问题标题】:TextBlock Using A C# Style String.Format For Text [duplicate]TextBlock 使用 C# 样式的 String.Format 文本 [重复]
【发布时间】:2014-11-09 04:04:39
【问题描述】:

C# 有一个函数 String.Format(string, arguments[]),其工作原理如下。

String.Format("here's my argument {0}", 1337)

这将返回字符串“这是我的参数 1337”。使用 TextBlock 对象,我无法获得这样的功能。我想做类似的事情

<TextBlock Text=String.Format("here's my argument {0}", {Binding Argument})/>

它将绑定作为输入,但我似乎找不到使用单个 TextBlock 执行此操作的任何方法。是否有类似的对象类型可以处理这个问题,或者有什么方法可以用文本块解决这个问题?

【问题讨论】:

标签: c# wpf xaml textblock string.format


【解决方案1】:

您可以为此使用StringFormat

<TextBlock Text="{Binding Argument, StringFormat=here\'s my argument {0}}"/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-13
    • 1970-01-01
    • 1970-01-01
    • 2011-05-28
    • 2012-06-13
    • 1970-01-01
    相关资源
    最近更新 更多