0
votes

I have a Grid with 5 columns of Width 160 each. I want a TextBlock (which Width is longer than Columns Width) to be at the centre-top of the window (let say in Centre of Column 2(3rd Col) and that the parts of text that exceeds the Column Width is shown in both rows beside. I tried HorizontalAlignment="Center", Canvas, RenderTransformOrigin, and other ways I searched, but doesn't work. Thanks in advance

1
are you looking for ColumnSpan.Abin
@AbinMathew, yes, it solved my question, thanks!user3351509

1 Answers

1
votes

I'm not exactly sure what you're asking, but I think you want the TextBlock to be visible along multiple columns? If so, set the Grid.ColumnSpan property on the TextBlock to 2.

<Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="160"/>
            <ColumnDefinition Width="160"/>
            <ColumnDefinition Width="160"/>
            <ColumnDefinition Width="160"/>
            <ColumnDefinition Width="160"/>
        </Grid.ColumnDefinitions>

        <TextBlock Grid.Column="2"
                   Grid.ColumnSpan="2"
                   HorizontalAlignment="Center"
                   Text="Hello"/>

</Grid>