How can I wrap text in a TextBlock?

I am new to windows phone7 development and have a little problem.

I have a text block (Label) in my interface, and at runtime I use this shortcut to display dyanamic data. The problem is that the text is too long (than the width of the screen), it displays only half of the data (only content that matches the width). It doesn’t matter to go to a few lines, but I want to display the full content. I tested the Textblock (Label) properties, but did not find any working ones.

Can someone please help me. (I am using Visual Studio 2010). Thanks


Below is the XAML

<Grid x:Name="LayoutRoot" Height="98"> <Ellipse Height="25" HorizontalAlignment="Left" Name="ellipse1" Stroke="Black" StrokeThickness="1" VerticalAlignment="Top" Width="46" Margin="6,13,0,0" Fill="#FFDB4C4C" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="66,10,0,0" Name="textBlock1" Text="TextBlock" VerticalAlignment="Top" Width="402" AllowDrop="False" TextWrapping="NoWrap" UseLayoutRounding="True" DataContext="{Binding}" /> <TextBlock Height="30" HorizontalAlignment="Left" Margin="66,44,0,0" Name="textBlock2" Text="TextBlock" VerticalAlignment="Top" Width="402" /> </Grid> 
+4
source share
1 answer

Setting the TextWrapping = "Wrap" property may solve your problem if there is enough free space.

EDIT

Depending on how you would like to resize, this should work:

 <Grid x:Name="LayoutRoot"> <Grid.RowDefinitions> <RowDefinition Height="auto" MinHeight="40" /> <RowDefinition Height="auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="60" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Ellipse Margin="5" Stroke="Black" StrokeThickness="1" Fill="#FFDB4C4C" /> <TextBlock HorizontalAlignment="Left" Margin="5" Name="textBlock1" VerticalAlignment="Top" TextWrapping="Wrap" UseLayoutRounding="True" Grid.Column="1" Text="sdfsdf sdf sdf sdf sd f sdf" /> <TextBlock HorizontalAlignment="Left" Margin="5" Name="textBlock2" VerticalAlignment="Top" TextWrapping="Wrap" Grid.Column="1" Grid.Row="1" Text="sdfsdf sdf sdf sdf sd f sdf" /> </Grid> 
+13
source

Source: https://habr.com/ru/post/1381475/


All Articles