运行时不显示整个文本时出现TextBlock

时间:2019-03-20 09:21:46

标签: c# wpf wpf-controls textblock

我正在构建一个wpf应用程序,其中该文本块文本在运行该应用程序时逐渐消失。 代码是

<Grid>
        <TextBlock Text="RSP Level" Width="78" Height="Auto" HorizontalAlignment="Left" Margin="54.2,3,0,398.6" Grid.Column="3"/>
        <TextBlock Text="Hex" Width="60" Height="Auto" HorizontalAlignment="Left" Grid.Column="3" Margin="157.2,36,0,367.6" RenderTransformOrigin="0.993,0.976" Grid.ColumnSpan="2"/>
        <TextBlock Text="Hex" Width="29" Height="20" TextWrapping="Wrap" HorizontalAlignment="Left" Grid.Column="3" Margin="31.2,35,0,368.6" RenderTransformOrigin="1.91,0.08" />
        <TextBlock Text="Link" Width="29" Height="20" HorizontalAlignment="Left" Grid.Column="3" Margin="31.2,59,0,344.6" RenderTransformOrigin="0.993,0.976"/>
        <TextBlock Text="Application" Width="61" Height="20" HorizontalAlignment="Left" Grid.Column="3" Margin="32.2,83,0,320.6" RenderTransformOrigin="0.993,0.976"/>
        <TextBlock Text="Physical" Width="66" Height="Auto" HorizontalAlignment="Left" Grid.Column="3" Margin="158.2,61,0,342.6" RenderTransformOrigin="0.993,0.976" Grid.ColumnSpan="2"/>
        <TextBlock Text="Link" Width="35" Height="Auto" HorizontalAlignment="Left" Grid.Column="3" Margin="158.2,85,0,318.6" RenderTransformOrigin="0.993,0.976"/>
        <TextBlock Text="Application" Width="69" Height="Auto" HorizontalAlignment="Left" Grid.Column="3" Margin="157.2,108,0,295.6" RenderTransformOrigin="0.993,0.976" Grid.ColumnSpan="2"/>
    </Grid>

enter image description here

1 个答案:

答案 0 :(得分:1)

这不是对齐内容的正确方法。您可以使用StackPanel将子元素放在下面或旁边。如果您使用Grid,请定义行和列。使用边距不是正确的方法。了解有关布局here的更多WPF。