简体   繁体   中英

TextBlock hosted inside StackPanel/Grid won't Wrap

TexBox放置在StackPanel / Grid内时,如何使TexBox具有非常长的文字环绕?

在TextBox控件(XAML)中,输入:

TextWrapping="Wrap"

You can put TextBox inside to StackPanel/Grid like this:

Stackpanel:

<StackPanel>
    <TexBox TextWrapping="Wrap"/>
</StackPanel>

Grid:

<Grid>
    <TexBox TextWrapping="Wrap"/>
</Grid>

If you set TextWrapping="WrapWithOverflow", it will hide everything that goes over it's height. In other words, height won't automatically change by its content.

StackPanel stretches accordingly to the size of its content. So if you use Grid and with TextWrapping you can achieve the desired result

<Grid>
        <TextBlock  
            TextWrapping="Wrap"
            Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus leo lectus, viverra ut lobortis vel, mollis eget lectus. Suspendisse laoreet consequat ultrices. Curabitur ultricies, tortor feugiat porttitor faucibus, lorem eros pretium nisl, eu ullamcorper mauris tortor sit amet augue." />
</Grid>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM