在绑定时将文本添加到TextBlock Text属性

Nic*_*ick 2 c# wpf binding text textblock

我有一个TextBlock地方,其Text财产与另一个属于一个价值的财产绑定:

<TextBlock Text="{Binding Path=Count}" FontWeight="Bold" />
Run Code Online (Sandbox Code Playgroud)

因此,如果(例如)Count4的,我将在我的TextBlock数见4.

现在,如果我想在数字4之前和之后添加一些文本,我必须做什么(例如我想在方括号[4]中看到这个数字)?

谢谢.

ígo*_*gor 5

你应该使用stringformat

<TextBlock Text="{Binding Path=Count, StringFormat={}[{0}]}" FontWeight="Bold" />
Run Code Online (Sandbox Code Playgroud)