<Button Margin="136,118,0,0" Width="148" Height="86">
<TextBlock Text="熊俊" Height="55" Width="93" HorizontalAlignment="Left" Foreground="Red"/>
</Button>Button是TextBlock的父元素,我在TextBlock中设置了对于父元素的水平对齐特征HorizontalAlignment属性值为Left,可是结果为什么没有靠左呢?
<TextBlock Text="熊俊" Height="55" Width="93" HorizontalAlignment="Left" Foreground="Red"/>
</Button>Button是TextBlock的父元素,我在TextBlock中设置了对于父元素的水平对齐特征HorizontalAlignment属性值为Left,可是结果为什么没有靠左呢?
<TextBlock Text="熊俊" Height="55" Width="93" HorizontalAlignment="Left" Foreground="Red"/>
</Button>
TextBlock是Button的Content,不管你怎设TextBlock都不会靠左的,只有设Button的Contewnt属性
这还要解解释,因为你的Button的Content是默认居中对齐的而且是大小是自动的,而不是Stretch你的TextBlock是在Button的Content中
你要是设Button的HorizontalContentAlignment="Stretch"后你的TextBlock才会起作用
你应去看一下ContentControl
你在textblock中设置左对齐只是把textblock上的文字左对齐,要让textblock在button中左对齐,必须在<button>中设置