[英]WPF: 2 different label sizes in particular order alignment
Please take a look at this picture: 请看这张照片:
I try to create same label with 2 sizes: 我尝试创建2种尺寸的相同标签:
<Grid>
<Label Content="11" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="50" />
<Label Content="%" HorizontalAlignment="Right" FontSize="20"
VerticalAlignment="Top"/>
</Grid>
But currently this is not like the picture: 但是目前这还不像图片:
To have such a result, your grid must be really small. 要获得这样的结果,您的网格必须很小。 I see at least 3 solutions to your issue:
对于您的问题,我至少看到3种解决方案:
1- Make your grid a bit bigger until it fits. 1-使您的网格更大,直到适合为止。
2- Put 2 columns in your grid, you'd put the number on the left column and the % on the right columns. 2-在网格中放置2列,将数字放在左列,将%放在右列。
3- You could use a StackPanel like this: 3-您可以像这样使用StackPanel:
<Grid>
<StackPanel Orientation="Horizontal">
<Label Content="11" FontSize="50" Padding="0"/>
<Label Content="%" FontSize="20" VerticalAlignment="Top" Padding="0,10,5,5"/>
</StackPanel>
</Grid>
EDIT: 编辑:
<Grid>
<StackPanel Orientation="Veritical">
<StackPanel Orientation="Horizontal">
<Label Content="11" FontSize="50" Padding="0"/>
<Label Content="%" FontSize="20" VerticalAlignment="Top" Padding="0,10,5,5"/>
</StackPanel>
<Label Content="Storage">
</StackPanel>
</Grid>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.