0

我想将按钮标题绑定到文件名,但我想在文件名之前和之后有修复文本。在没有代码的情况下,这在 xaml 中是否可行?

像这样的东西:

<Button Header="Save {Binding ActiveDocument.FileName} as..." Command="{Binding ActiveDocument.SaveAsCommand}" />
4

1 回答 1

1

Well I have never tried that to be honest. But Binding object has StringFormat property. So you can simply try this.

<Button Content="{Binding ActiveDocument.FileName, StringFormat='Save {0} as...'}" Command="{Binding ActiveDocument.SaveAsCommand}" />

another possible way is setting Buttons ContentStringFormat property

<Button Content="{Binding ActiveDocument.FileName}" ContentStringFormat="Save {0} as..." Command="{Binding ActiveDocument.SaveAsCommand}" />
于 2012-11-22T21:32:05.547 回答