我想在底部有一个带文字的按钮,但背景中有更多文字,特别是UI字体。这样,底部的内容文本可以在后台看到。
看起来StackPanels和DockPanels似乎没有帮助,因为它们总是为每个控件分配空间,因此它们不会重叠。
类似的东西:
<Button HorizontalContentAlignment="Stretch" VerticalContentAlignment="Bottom" FontFamily="Segoe UI Symbol">
<Button.Background>
<TextBox Text="" Foreground="White" Background="#FF5B9BD5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" BorderThickness="0"/>
</Button.Background>
<TextBox Text="Text" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" BorderThickness="0"/>
</Button>
此代码不起作用,因为Background不支持控件,只支持Brushes。
答案 0 :(得分:0)
使用网格实现了这一目标:
<Button VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" Foreground="White" FontFamily="Segoe UI Symbol" FontStretch="Expanded" BorderThickness="0">
<Grid>
<TextBox Text="" Foreground="White" Background="#FF5B9BD5" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontSize="36" BorderThickness="0"/>
<TextBox Text="Text" Foreground="White" Background="#FF5B9BD5" HorizontalContentAlignment="Center" VerticalAlignment="Bottom" BorderThickness="0"/>
</Grid>
</Button>