我在WPF中有一个详细信息视图窗口,标签可能如下所示.
<Label Content="{x:Static properties:Resources.Reference}" />
Run Code Online (Sandbox Code Playgroud)
这是从我的属性Resource获取它的内容.
如何转换/格式化内容,使其在每个标签项后都有一个冒号.例如,而不是简单地显示参考的内容,我希望它转换为参考:
All*_*lan 19
我最终得到的解决方案是:
<Label Content="{x:Static properties:Resources.Reference}" ContentStringFormat="{}{0}:"/>
Run Code Online (Sandbox Code Playgroud)
您可以使用Bindingwith StringFormat来格式化结果.
<Label Content="{Binding Source={x:Static properties:Resource.Reference}, StringFormat='{}{0}:'}"
Run Code Online (Sandbox Code Playgroud)
请注意,{}格式字符串之前是为了防止XAML解析器将其{0}视为标记扩展,{StaticResource}例如.
| 归档时间: |
|
| 查看次数: |
2498 次 |
| 最近记录: |