开发者

XAML text binding

I would bind a string property to text property like this: T开发者_开发问答ext="{Binding propertyName}.

I also want to append a hardcoded string to this like Text="{Binding propertyName} appendedName. How to do this?


Text="{Binding propertyName,StringFormat='Your property is: {}{0}'}"


You could use Run Text:

<TextBlock>
<Run Text="{Binding YourBinding}"/>
<Run Text="Suffix"/>
</TextBlock>

If you want to use it like this several times I would recommend a TemplatedControl where you have a Suffix DependencyProperty and a Text DependencyProperty.


You should create new property that returns text + appendedName.
Another way is to use several text blocks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜