stackpanel Horizontal wrap text WP 8.1

115 views Asked by At

code:

<code>
<StackPanel Orientation="Horizontal">
                    <TextBlock Text="Key1:" FontSize="20" Foreground="#73000000" TextWrapping="Wrap"/>
                    <Grid><TextBlock Text="Small Value1" FontSize="20" TextWrapping="Wrap" />
                        </Grid>
                </StackPanel>

                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Key2:" FontSize="20" Foreground="#73000000" TextWrapping="Wrap"/>
                    <Grid>
                        <TextBlock Text="Long Long Long Long Long LongLongLong Long Long LongValue2" FontSize="20" TextWrapping="Wrap" />
                    </Grid>
                </StackPanel>
</code>

Image screen shot:

enter image description here

I need to make the transfer of values to a new line if it is longer than the screen.

2

There are 2 answers

1
Murtaza Munshi On

Try using Wrap whole word attribute

<TextBlock TextWrapping="WrapWholeWords">
0
AlexeySRG On
<TextBlock x:Name="TextBlock1" TextWrapping="Wrap" FontSize="20">
                <Run Foreground="#73000000">Key:</Run>
                <Run Text="{Binding Tag, ElementName=TextBlock1}"/>
            </TextBlock>

TextBlock1.Tag = "Long Long Long Long Long Long Long Long LongValue";