代码之家  ›  专栏  ›  技术社区  ›  Jose

对齐按钮内容

  •  26
  • Jose  · 技术社区  · 15 年前

    我尝试了以下操作,但文本仍在按钮内居中。

        <Button >
            <StackPanel HorizontalAlignment="Stretch">
                <TextBlock HorizontalAlignment="Left" Text="Save"/>
            </StackPanel>
        </Button>
    

    我该怎么办?

    3 回复  |  直到 13 年前
        1
  •  64
  •   brunnerh    13 年前

    找到了,它是 HorizontalContentAlignment .

    :)

        2
  •  16
  •   Bryan Anderson    15 年前

    您不需要StackPanel或TextBlock。你所需要的只是

    <Button HorizontalContentAlignment="Left" Content="Save" />
    
        3
  •  5
  •   daniele3004    8 年前

    您可以以水平和垂直两种方式对齐

    <Button Content="Export" VerticalContentAlignment="Bottom" name="MyBtn1"  />
    

    <Button Content="Export" HorizontalContentAlignment="Center" name="MyBtn2"  />
    

    请参见下图以查看可能性设置:

    enter image description here

    enter image description here