网格内部按钮不会水平拉伸

时间:2015-04-20 09:03:29

标签: xaml windows-phone-8.1

鉴于以下标记,我原本希望V形图标一直到按钮的右边,但它没有 - 相反,堆叠面板和V形按钮在按钮中间紧密相连。

<Button Background="Teal" HorizontalAlignment="Stretch">
    <Grid HorizontalAlignment="Stretch">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"></ColumnDefinition>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
        </Grid.ColumnDefinitions>

        <StackPanel HorizontalAlignment="Stretch"
                    Grid.Column="0">
            <TextBlock HorizontalAlignment="Center"
                       TextAlignment="Center"
                       FontSize="60">Click!</TextBlock>
            <TextBlock HorizontalAlignment="Stretch"
                       TextAlignment="Center"
                       FontSize="20">Cool things will happen</TextBlock>
        </StackPanel>
        <TextBlock Grid.Column="1"
                   FontSize="60"
                   FontFamily="Segoe UI Symbol">
            &#xe013; <!-- unicode for chevron right in this font -->
        </TextBlock>
    </Grid>
</Button>

Chevron should be all the way to the right

1 个答案:

答案 0 :(得分:3)

您可以尝试将按钮的HorizontalContentAlignment设置为Stretch