2009-06-02 108 views
20

我想要一个wpf按钮的内容左对齐 我尝试了以下操作,但文本仍然位于按钮中央。对齐按钮内容

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

我该怎么办?

回答

14

你不需要的StackPanel或TextBlock的。所有你需要的是

<Button HorizontalContentAlignment="Left" Content="Save" /> 
+1

实际执行过的内容两个元素,我的例子中没有 – Jose 2009-06-03 12:52:08

4

您可以通过两种方式,水平调整和垂直

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

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

见后续图像查看准备设置:

enter image description here

enter image description here