How to start wrapping of a textblock from second row of a Grid?












0














I have 2 rows in a grid. In first row I have 5 columns, in every column I have a textblock. In second row I have a divider.
Can I wrap the last textblock so that it should start from the second row of the grid?
Currently this is my xaml code.



<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>

<TextBlock Text="{Binding FullName}" Grid.Row="0" Grid.Column="0" x:Name="firstName" Visibility="{Binding FullName, Converter={StaticResource NullOrWhiteSpaceConverter}}" TextAlignment="Left"/>
<TextBlock Text=" | " FontWeight="Bold" Foreground="#008DFC" Grid.Column="1" Grid.Row="0" Margin="0,0,0,0" Visibility="{Binding Visibility,ElementName=firstlevel}" HorizontalAlignment="Left"/>
<TextBlock Text="{Binding FirstLevelParent}" Grid.Row="0" Margin="10,0,0,0" Visibility="{Binding FirstLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" x:Name="firstlevel" Grid.Column="1" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="1" Grid.Row="0" Visibility="{Binding Visibility,ElementName=middleName}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding SecondLevelParent}" Grid.Row="0" Margin="10,0,0,0" Visibility="{Binding SecondLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" x:Name="middleName" Grid.Column="2" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="2" Grid.Row="0" Visibility="{Binding Visibility,ElementName=lastName}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding ThreeLevelParent}" Grid.Row="0" Margin="10,0,0,0" x:Name="lastName" Visibility="{Binding ThreeLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" Grid.Column="3" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="3" Grid.Row="0" Visibility="{Binding Visibility,ElementName=fourlevel}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding FourLevelParent}" TextWrapping="Wrap" Grid.Row="0" Margin="10,0,0,0" x:Name="fourlevel" Visibility="{Binding FourLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" Grid.Column="4" TextAlignment="Left"/>

<Grid Grid.Row="1" x:Name="deliverypoint" Visibility="Collapsed">
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>-->
<TextBlock Text="{Binding DeliveryPoint}" x:Name="deliverypointname" TextAlignment="Left" Foreground="Black" FontSize="12"/>
</Grid>
<!--<TextBlock Text="|" Grid.Column="2" Margin="0,0,-6,0" Visibility="{Binding Visibility,ElementName=lastName}" HorizontalAlignment="Right"/>-->
</Grid>
<TextBlock TextWrapping="NoWrap" Text="-------------------------------------------------------------------------" Grid.Row="1"/>
</Grid>




Thanks in advance.Auto suggest last text block wrapping.










share|improve this question
























  • I could not understand what you're doing. Could you draw a diagram to describe the effect you want?
    – Xavier Xie - MSFT
    Nov 21 at 6:43










  • Added current implantation screenshot. Can the wrapping of the last text block start from the next line?
    – tushargoyal1309
    Nov 21 at 7:01
















0














I have 2 rows in a grid. In first row I have 5 columns, in every column I have a textblock. In second row I have a divider.
Can I wrap the last textblock so that it should start from the second row of the grid?
Currently this is my xaml code.



<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>

<TextBlock Text="{Binding FullName}" Grid.Row="0" Grid.Column="0" x:Name="firstName" Visibility="{Binding FullName, Converter={StaticResource NullOrWhiteSpaceConverter}}" TextAlignment="Left"/>
<TextBlock Text=" | " FontWeight="Bold" Foreground="#008DFC" Grid.Column="1" Grid.Row="0" Margin="0,0,0,0" Visibility="{Binding Visibility,ElementName=firstlevel}" HorizontalAlignment="Left"/>
<TextBlock Text="{Binding FirstLevelParent}" Grid.Row="0" Margin="10,0,0,0" Visibility="{Binding FirstLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" x:Name="firstlevel" Grid.Column="1" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="1" Grid.Row="0" Visibility="{Binding Visibility,ElementName=middleName}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding SecondLevelParent}" Grid.Row="0" Margin="10,0,0,0" Visibility="{Binding SecondLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" x:Name="middleName" Grid.Column="2" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="2" Grid.Row="0" Visibility="{Binding Visibility,ElementName=lastName}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding ThreeLevelParent}" Grid.Row="0" Margin="10,0,0,0" x:Name="lastName" Visibility="{Binding ThreeLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" Grid.Column="3" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="3" Grid.Row="0" Visibility="{Binding Visibility,ElementName=fourlevel}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding FourLevelParent}" TextWrapping="Wrap" Grid.Row="0" Margin="10,0,0,0" x:Name="fourlevel" Visibility="{Binding FourLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" Grid.Column="4" TextAlignment="Left"/>

<Grid Grid.Row="1" x:Name="deliverypoint" Visibility="Collapsed">
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>-->
<TextBlock Text="{Binding DeliveryPoint}" x:Name="deliverypointname" TextAlignment="Left" Foreground="Black" FontSize="12"/>
</Grid>
<!--<TextBlock Text="|" Grid.Column="2" Margin="0,0,-6,0" Visibility="{Binding Visibility,ElementName=lastName}" HorizontalAlignment="Right"/>-->
</Grid>
<TextBlock TextWrapping="NoWrap" Text="-------------------------------------------------------------------------" Grid.Row="1"/>
</Grid>




Thanks in advance.Auto suggest last text block wrapping.










share|improve this question
























  • I could not understand what you're doing. Could you draw a diagram to describe the effect you want?
    – Xavier Xie - MSFT
    Nov 21 at 6:43










  • Added current implantation screenshot. Can the wrapping of the last text block start from the next line?
    – tushargoyal1309
    Nov 21 at 7:01














0












0








0







I have 2 rows in a grid. In first row I have 5 columns, in every column I have a textblock. In second row I have a divider.
Can I wrap the last textblock so that it should start from the second row of the grid?
Currently this is my xaml code.



<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>

<TextBlock Text="{Binding FullName}" Grid.Row="0" Grid.Column="0" x:Name="firstName" Visibility="{Binding FullName, Converter={StaticResource NullOrWhiteSpaceConverter}}" TextAlignment="Left"/>
<TextBlock Text=" | " FontWeight="Bold" Foreground="#008DFC" Grid.Column="1" Grid.Row="0" Margin="0,0,0,0" Visibility="{Binding Visibility,ElementName=firstlevel}" HorizontalAlignment="Left"/>
<TextBlock Text="{Binding FirstLevelParent}" Grid.Row="0" Margin="10,0,0,0" Visibility="{Binding FirstLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" x:Name="firstlevel" Grid.Column="1" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="1" Grid.Row="0" Visibility="{Binding Visibility,ElementName=middleName}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding SecondLevelParent}" Grid.Row="0" Margin="10,0,0,0" Visibility="{Binding SecondLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" x:Name="middleName" Grid.Column="2" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="2" Grid.Row="0" Visibility="{Binding Visibility,ElementName=lastName}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding ThreeLevelParent}" Grid.Row="0" Margin="10,0,0,0" x:Name="lastName" Visibility="{Binding ThreeLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" Grid.Column="3" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="3" Grid.Row="0" Visibility="{Binding Visibility,ElementName=fourlevel}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding FourLevelParent}" TextWrapping="Wrap" Grid.Row="0" Margin="10,0,0,0" x:Name="fourlevel" Visibility="{Binding FourLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" Grid.Column="4" TextAlignment="Left"/>

<Grid Grid.Row="1" x:Name="deliverypoint" Visibility="Collapsed">
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>-->
<TextBlock Text="{Binding DeliveryPoint}" x:Name="deliverypointname" TextAlignment="Left" Foreground="Black" FontSize="12"/>
</Grid>
<!--<TextBlock Text="|" Grid.Column="2" Margin="0,0,-6,0" Visibility="{Binding Visibility,ElementName=lastName}" HorizontalAlignment="Right"/>-->
</Grid>
<TextBlock TextWrapping="NoWrap" Text="-------------------------------------------------------------------------" Grid.Row="1"/>
</Grid>




Thanks in advance.Auto suggest last text block wrapping.










share|improve this question















I have 2 rows in a grid. In first row I have 5 columns, in every column I have a textblock. In second row I have a divider.
Can I wrap the last textblock so that it should start from the second row of the grid?
Currently this is my xaml code.



<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>

<TextBlock Text="{Binding FullName}" Grid.Row="0" Grid.Column="0" x:Name="firstName" Visibility="{Binding FullName, Converter={StaticResource NullOrWhiteSpaceConverter}}" TextAlignment="Left"/>
<TextBlock Text=" | " FontWeight="Bold" Foreground="#008DFC" Grid.Column="1" Grid.Row="0" Margin="0,0,0,0" Visibility="{Binding Visibility,ElementName=firstlevel}" HorizontalAlignment="Left"/>
<TextBlock Text="{Binding FirstLevelParent}" Grid.Row="0" Margin="10,0,0,0" Visibility="{Binding FirstLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" x:Name="firstlevel" Grid.Column="1" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="1" Grid.Row="0" Visibility="{Binding Visibility,ElementName=middleName}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding SecondLevelParent}" Grid.Row="0" Margin="10,0,0,0" Visibility="{Binding SecondLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" x:Name="middleName" Grid.Column="2" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="2" Grid.Row="0" Visibility="{Binding Visibility,ElementName=lastName}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding ThreeLevelParent}" Grid.Row="0" Margin="10,0,0,0" x:Name="lastName" Visibility="{Binding ThreeLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" Grid.Column="3" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" Grid.Column="3" Grid.Row="0" Visibility="{Binding Visibility,ElementName=fourlevel}" Margin="0,0,-10,0" HorizontalAlignment="Right"/>
<TextBlock Text="{Binding FourLevelParent}" TextWrapping="Wrap" Grid.Row="0" Margin="10,0,0,0" x:Name="fourlevel" Visibility="{Binding FourLevelParent, Converter={StaticResource NullOrWhiteSpaceConverter}}" Grid.Column="4" TextAlignment="Left"/>

<Grid Grid.Row="1" x:Name="deliverypoint" Visibility="Collapsed">
<!--<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>-->
<TextBlock Text="{Binding DeliveryPoint}" x:Name="deliverypointname" TextAlignment="Left" Foreground="Black" FontSize="12"/>
</Grid>
<!--<TextBlock Text="|" Grid.Column="2" Margin="0,0,-6,0" Visibility="{Binding Visibility,ElementName=lastName}" HorizontalAlignment="Right"/>-->
</Grid>
<TextBlock TextWrapping="NoWrap" Text="-------------------------------------------------------------------------" Grid.Row="1"/>
</Grid>




Thanks in advance.Auto suggest last text block wrapping.







xaml uwp grid textblock textwrapping






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 6:57

























asked Nov 20 at 8:21









tushargoyal1309

438




438












  • I could not understand what you're doing. Could you draw a diagram to describe the effect you want?
    – Xavier Xie - MSFT
    Nov 21 at 6:43










  • Added current implantation screenshot. Can the wrapping of the last text block start from the next line?
    – tushargoyal1309
    Nov 21 at 7:01


















  • I could not understand what you're doing. Could you draw a diagram to describe the effect you want?
    – Xavier Xie - MSFT
    Nov 21 at 6:43










  • Added current implantation screenshot. Can the wrapping of the last text block start from the next line?
    – tushargoyal1309
    Nov 21 at 7:01
















I could not understand what you're doing. Could you draw a diagram to describe the effect you want?
– Xavier Xie - MSFT
Nov 21 at 6:43




I could not understand what you're doing. Could you draw a diagram to describe the effect you want?
– Xavier Xie - MSFT
Nov 21 at 6:43












Added current implantation screenshot. Can the wrapping of the last text block start from the next line?
– tushargoyal1309
Nov 21 at 7:01




Added current implantation screenshot. Can the wrapping of the last text block start from the next line?
– tushargoyal1309
Nov 21 at 7:01












1 Answer
1






active

oldest

votes


















0














I suggested that you do not use 'Grid.ColumnDefinition' to layout your TextBlock. Instead, you could use WrapPanel XAML Control to wrap these TextBlock. Once the max width or height is reached the control automatically create row or column based on the orientation.



I made a simple code sample for your reference:



<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition />
</Grid.RowDefinitions>
<controls:WrapPanel Orientation="Horizontal" HorizontalSpacing="10">
<TextBlock Text="FullName" x:Name="firstName" TextAlignment="Left"/>
<TextBlock Text=" | " FontWeight="Bold" Foreground="#008DFC" HorizontalAlignment="Left"/>
<TextBlock Text="FirstLevelParent" x:Name="firstlevel" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="SecondLevelParent" x:Name="middleName" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="ThreeLevelParent" x:Name="lastName" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="FourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParent" x:Name="fourlevel" TextAlignment="Left" TextWrapping="Wrap"/>
</controls:WrapPanel>
<TextBlock TextWrapping="NoWrap" Text="---------------------------------------------------------------------------------------" VerticalAlignment="Top" Grid.Row="1"/>
</Grid>


enter image description here



enter image description here






share|improve this answer





















  • Thank you so much @Xavier Xie. This was a bug since I started the app development and thought I would resolve it in the end, I think it is that time now. Thanks again.
    – tushargoyal1309
    Nov 21 at 9:25











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388822%2fhow-to-start-wrapping-of-a-textblock-from-second-row-of-a-grid%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I suggested that you do not use 'Grid.ColumnDefinition' to layout your TextBlock. Instead, you could use WrapPanel XAML Control to wrap these TextBlock. Once the max width or height is reached the control automatically create row or column based on the orientation.



I made a simple code sample for your reference:



<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition />
</Grid.RowDefinitions>
<controls:WrapPanel Orientation="Horizontal" HorizontalSpacing="10">
<TextBlock Text="FullName" x:Name="firstName" TextAlignment="Left"/>
<TextBlock Text=" | " FontWeight="Bold" Foreground="#008DFC" HorizontalAlignment="Left"/>
<TextBlock Text="FirstLevelParent" x:Name="firstlevel" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="SecondLevelParent" x:Name="middleName" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="ThreeLevelParent" x:Name="lastName" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="FourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParent" x:Name="fourlevel" TextAlignment="Left" TextWrapping="Wrap"/>
</controls:WrapPanel>
<TextBlock TextWrapping="NoWrap" Text="---------------------------------------------------------------------------------------" VerticalAlignment="Top" Grid.Row="1"/>
</Grid>


enter image description here



enter image description here






share|improve this answer





















  • Thank you so much @Xavier Xie. This was a bug since I started the app development and thought I would resolve it in the end, I think it is that time now. Thanks again.
    – tushargoyal1309
    Nov 21 at 9:25
















0














I suggested that you do not use 'Grid.ColumnDefinition' to layout your TextBlock. Instead, you could use WrapPanel XAML Control to wrap these TextBlock. Once the max width or height is reached the control automatically create row or column based on the orientation.



I made a simple code sample for your reference:



<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition />
</Grid.RowDefinitions>
<controls:WrapPanel Orientation="Horizontal" HorizontalSpacing="10">
<TextBlock Text="FullName" x:Name="firstName" TextAlignment="Left"/>
<TextBlock Text=" | " FontWeight="Bold" Foreground="#008DFC" HorizontalAlignment="Left"/>
<TextBlock Text="FirstLevelParent" x:Name="firstlevel" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="SecondLevelParent" x:Name="middleName" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="ThreeLevelParent" x:Name="lastName" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="FourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParent" x:Name="fourlevel" TextAlignment="Left" TextWrapping="Wrap"/>
</controls:WrapPanel>
<TextBlock TextWrapping="NoWrap" Text="---------------------------------------------------------------------------------------" VerticalAlignment="Top" Grid.Row="1"/>
</Grid>


enter image description here



enter image description here






share|improve this answer





















  • Thank you so much @Xavier Xie. This was a bug since I started the app development and thought I would resolve it in the end, I think it is that time now. Thanks again.
    – tushargoyal1309
    Nov 21 at 9:25














0












0








0






I suggested that you do not use 'Grid.ColumnDefinition' to layout your TextBlock. Instead, you could use WrapPanel XAML Control to wrap these TextBlock. Once the max width or height is reached the control automatically create row or column based on the orientation.



I made a simple code sample for your reference:



<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition />
</Grid.RowDefinitions>
<controls:WrapPanel Orientation="Horizontal" HorizontalSpacing="10">
<TextBlock Text="FullName" x:Name="firstName" TextAlignment="Left"/>
<TextBlock Text=" | " FontWeight="Bold" Foreground="#008DFC" HorizontalAlignment="Left"/>
<TextBlock Text="FirstLevelParent" x:Name="firstlevel" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="SecondLevelParent" x:Name="middleName" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="ThreeLevelParent" x:Name="lastName" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="FourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParent" x:Name="fourlevel" TextAlignment="Left" TextWrapping="Wrap"/>
</controls:WrapPanel>
<TextBlock TextWrapping="NoWrap" Text="---------------------------------------------------------------------------------------" VerticalAlignment="Top" Grid.Row="1"/>
</Grid>


enter image description here



enter image description here






share|improve this answer












I suggested that you do not use 'Grid.ColumnDefinition' to layout your TextBlock. Instead, you could use WrapPanel XAML Control to wrap these TextBlock. Once the max width or height is reached the control automatically create row or column based on the orientation.



I made a simple code sample for your reference:



<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition />
</Grid.RowDefinitions>
<controls:WrapPanel Orientation="Horizontal" HorizontalSpacing="10">
<TextBlock Text="FullName" x:Name="firstName" TextAlignment="Left"/>
<TextBlock Text=" | " FontWeight="Bold" Foreground="#008DFC" HorizontalAlignment="Left"/>
<TextBlock Text="FirstLevelParent" x:Name="firstlevel" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="SecondLevelParent" x:Name="middleName" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="ThreeLevelParent" x:Name="lastName" TextAlignment="Left"/>
<TextBlock Text=" | " Foreground="#008DFC" FontWeight="Bold" HorizontalAlignment="Right"/>
<TextBlock Text="FourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParentFourLevelParent" x:Name="fourlevel" TextAlignment="Left" TextWrapping="Wrap"/>
</controls:WrapPanel>
<TextBlock TextWrapping="NoWrap" Text="---------------------------------------------------------------------------------------" VerticalAlignment="Top" Grid.Row="1"/>
</Grid>


enter image description here



enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 at 8:02









Xavier Xie - MSFT

4,8861315




4,8861315












  • Thank you so much @Xavier Xie. This was a bug since I started the app development and thought I would resolve it in the end, I think it is that time now. Thanks again.
    – tushargoyal1309
    Nov 21 at 9:25


















  • Thank you so much @Xavier Xie. This was a bug since I started the app development and thought I would resolve it in the end, I think it is that time now. Thanks again.
    – tushargoyal1309
    Nov 21 at 9:25
















Thank you so much @Xavier Xie. This was a bug since I started the app development and thought I would resolve it in the end, I think it is that time now. Thanks again.
– tushargoyal1309
Nov 21 at 9:25




Thank you so much @Xavier Xie. This was a bug since I started the app development and thought I would resolve it in the end, I think it is that time now. Thanks again.
– tushargoyal1309
Nov 21 at 9:25


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388822%2fhow-to-start-wrapping-of-a-textblock-from-second-row-of-a-grid%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

RAC Tourist Trophy