WPF,这个布局为什么不靠左
<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中设置HorizontalAlignment这个是表示TextBlock中显示的文字的对齐特征
[解决办法]
我很好奇,从图片上面我已经看到了左对齐了,textblock不就是靠左了? 至于textblock的容器button是很明显无法左对齐的,因为设置了margin
[解决办法]
<Button HorizontalContentAlignment="Left Margin="136,118,0,0" Width="148" Height="86">
<TextBlock Text="熊俊" Height="55" Width="93" HorizontalAlignment="Left" Foreground="Red"/>
</Button>
TextBlock是Button的Content,不管你怎设TextBlock都不会靠左的,只有设Button的Contewnt属性
[解决办法]
你在TextBlock中设置HorizontalAlignment这个是表示TextBlock中显示的文字的对齐特征
阁下说的是TextAlignment属性吧。看清楚哦