我想知道是否可以在 WPF 中将 Button
的文本定义为:
b c
我试过设置 alt text http://img651.imageshack.us/img651/1838/ctldhrzhy41gbrcch4dpjz4.png
但这似乎不起作用。
Bold
标签是否只能与 FlowDocument
一起使用?
谢谢
最佳答案
使用 TextBlock
来保存格式化的文本:
<Button>
<TextBlock>Hey <Bold>you</Bold>!!!</TextBlock>
</Button>
根据您的评论,如果您想明确说明这会设置 Content
属性,您可以使用 XAML 属性元素语法来实现:
<Button>
<Button.Content>
<TextBlock>Hey <Bold>you</Bold>!!!</TextBlock>
</Button.Content>
</Button>
但是这是多余的,因为 Button
有一个 ContentPropertyAttribute
,这使得第一个版本与第二个版本完全相同。
关于c# - 将按钮的文本设置为在 WPF 中有一些粗体字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2277770/