如何指定由一些文本和绑定(bind)路径混合而成的按钮的内容?
像这样:
<Button Content= "TEXT" + "{Binding Path=ButtonContent}"
最佳答案
对于大多数情况,您可以在绑定(bind)中使用 StringFormat,例如 TextBlock
<TextBlock Text="{Binding ElementName=textBox,
Path=Text,
StringFormat='{}{0} - Added Text'}"/>
但是,这对 ContentControl
(Button
继承自)没有影响。相反,您可以使用 ContentStringFormat
<Button Content="{Binding ElementName=textBox,
Path=Text}"
ContentStringFormat="{}{0} - Added Text"/>
另外,对于
ContentControl
您使用ContentStringFormat
HeaderedContentControl
您使用HeaderStringFormat
ItemsControl
您使用ItemStringFormat
关于wpf - 指定具有文本和绑定(bind)路径混合的按钮内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5159540/