我想要Content
我的 WPFButton
使用多种颜色,例如:
<Button Name="MyButton">
<Blue>This is</Blue>
<Red>Red</Red>
</Button>
我发现我不能使用多个Run
就像在一个TextBlock
- 达到这种效果的正确方法是什么?
您可以使用TextBlock
as Button.Content
<Button Name="MyButton">
<TextBlock>
<Run Foreground="Blue" Text="This is Blue"/>
<Run Foreground="Red" Text=" This is Red"/>
</TextBlock>
</Button>
Button
is ContentControl https://msdn.microsoft.com/en-us/library/system.windows.controls.contentcontrol(v=vs.110).aspx因此
ContentControl 可以包含任何类型的公共语言运行时对象(例如字符串或 DateTime 对象)或 UIElement 对象(例如 Rectangle 或 Panel)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)