wpf - XAML 中的 String.Format 没有绑定
问题描述
我需要像这样连接一些字符串的各种组合:
"After doing this and that, press the 'whatever'-button."
有多种组合可能,为了保证将来的安全,我想做一些
String.Format("After doing this and that, press the '{0}'-button.", "whatever");
使用来自字符串资源的字符串。
我发现的是:
<!-- Strings.Temperature contains: "Temperature: {0} °C" -->
Text="{Binding Temperature, StringFormat={x:Static loc:Strings.Temperature}}" />
甚至:
<TextBlock.Text>
<!-- Strings.Temperature contains: "Temperature: {0} °C / {1} °F" -->
<MultiBinding StringFormat=StringFormat={x:Static loc:Strings.Temperature}>
<Binding Path="{Binding TemperatureCelcius}" />
<Binding Path="{Binding TemperatureFahrenheit}" />
</MultiBinding>
</TextBlock.Text>
但我没有绑定到“值”字符串。它也是一个静态变量。而且我知道我真的可以将它绑定到一些视图模型字符串属性,但我不想在不同的视图模型中产生这么多的开销。
有任何想法吗?
解决方案
推荐阅读
- javascript - 如何在玉中包含每次迭代的模态?
- javascript - 使用 PHP 从 APP Engine 应用程序向 Gmail 地址发送电子邮件
- c# - 读取 XMLStreamReader 时出错。获取故障响应
- javascript - 表格中的复选框选择
- r - 使用不同的行值来创建函数
- ios - 如何在 ios swift 中执行另一个数据任务线程时暂停数据任务线程一段时间?
- hadoop - 在 Hadoop 中启用 RM HA 时,备用 ResourceManager (RM) 如何变为活动状态
- python - ImportError en el jupyter notebook 尽管安装了名为的库
- qt - 如何在 Qt 中使用 QImage 更改图像中的文本(前景)和背景颜色?
- python - 张量必须来自与张量相同的图