在xaml中进行绑定后是否可以添加更多字符? [英] Is it possible to add more characters after a binding in xaml?
问题描述
我在想什么,找不到任何相关主题.我有以下绑定:
I was wondering something, and couldn't find any relevant topics. I have following binding :
Content="{x:Static resx:Resource.Form_OtherOption_Description}"
这将在标签中放置一个字符串.我问自己的意思是,是否可以在该绑定之后添加一个:",而不是在代码中添加Xaml.标签代表类似名称:"的名称.但是,不能将:"作为绑定的一部分.
This will place a string in a label. What i was asking myself is if i can add a ":" after that binding, not in code, just in xaml. The label represent something like "Name :". But adding the ":" as part of the binding is not an option.
修改
我正在使用3.5版本
任何建议.
谢谢.
推荐答案
您可以使用以下方法来实现此目的:
You could accomplish this with something like:
<TextBlock Text="{Binding Source={x:Static resx:Resource.Form_OtherOption_Description},
StringFormat={}{0}:}" />
:<Label>
的Content
属性显然不遵守绑定的StringFormat
属性.我发现的内容已移至<Label>
的ContentStringFormat
属性.
<Label>
s Content
property does not respect the StringFormat
property of a binding apparently. Which I've found has been moved to the ContentStringFormat
property on the <Label>
.
<Label Content="{x:Static resx:Resource.Form_OtherOption_Description}"
ContentStringFormat="{}{0}:" />
这篇关于在xaml中进行绑定后是否可以添加更多字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!