简体   繁体   English

StackPanel / Grid中托管的TextBlock不会自动换行

[英]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: 您可以像这样将TextBox放入StackPanel / Grid中:

Stackpanel: 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. 如果设置TextWrapping =“ WrapWithOverflow”,它将隐藏超出其高度的所有内容。 In other words, height won't automatically change by its content. 换句话说,高度不会根据其内容自动更改。

StackPanel stretches accordingly to the size of its content. StackPanel会相应地扩展其内容的大小。 So if you use Grid and with TextWrapping you can achieve the desired result 因此,如果您使用Grid并使用TextWrapping,则可以实现所需的结果

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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