WPF Canvas子控件Label无法居中
前台XAML代码:<CanvasName="hscrollCanvas"Grid.Column="0"ClipToBounds="True"><LabelName="lb...
前台XAML代码:
<Canvas Name="hscrollCanvas" Grid.Column="0" ClipToBounds="True"> <Label Name="lbMessage" Height="50" FontSize="32" FontWeight="Bold" VerticalContentAlignment="Top" FontFamily="STZhongsong" Margin="0,0,0,0" Foreground="White" TextOptions.TextFormattingMode="Display" TextOptions.TextHintingMode="Fixed" TextOptions.TextRenderingMode="ClearType"/> </Canvas>
后台CS代码:
hscrollCanvas.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; lbMessage.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; lbMessage.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
我这样设置了为啥lbMessage的内容没有居中啊 展开
<Canvas Name="hscrollCanvas" Grid.Column="0" ClipToBounds="True"> <Label Name="lbMessage" Height="50" FontSize="32" FontWeight="Bold" VerticalContentAlignment="Top" FontFamily="STZhongsong" Margin="0,0,0,0" Foreground="White" TextOptions.TextFormattingMode="Display" TextOptions.TextHintingMode="Fixed" TextOptions.TextRenderingMode="ClearType"/> </Canvas>
后台CS代码:
hscrollCanvas.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; lbMessage.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; lbMessage.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
我这样设置了为啥lbMessage的内容没有居中啊 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询