[英]How to wrap with enter in textblock?
抱歉,這個標題有點“誤導”。 但是我想了解為什么當我按Enter鍵時我的TextBlock不能換行,這是控件的問題嗎? 也許效果不好? 這是我的xaml代碼:
<Window x:Class="SF_DebugProject.Information"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Info" Height="400" Width="500">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid Grid.Column="0" Grid.Row="0">
<Label>dfdfdfd dfdfd</Label>
</Grid>
<Grid Grid.Column="0" Grid.Row="2">
<Label>
<TextBlock TextWrapping="WrapWithOverflow">
dfdfd diofsidi sdjoif
dfd this should be wrap...
</TextBlock>
</Label>
</Grid>
</Grid>
這是我告訴您的內容的預覽:
如您所見,文本塊的第二行沒有換行,但在第一行保持停止。 是什么原因造成的?
在TextBlock
手動換行時,您幾乎沒有選擇。 您可以使用LineBreak
<TextBlock TextWrapping="WrapWithOverflow">
dfdfd diofsidi sdjoif
<LineBreak/>
dfd this should be wrap...
</TextBlock>
或針對TextBlock
設置xml:space="preserve"
,但這還將在每行之前保留空格
<TextBlock TextWrapping="WrapWithOverflow" xml:space="preserve">
dfdfd diofsidi sdjoif
dfd this should be wrap...
</TextBlock>
第三種選擇是在Text
換行符
<TextBlock
TextWrapping="WrapWithOverflow"
Text="dfdfd diofsidi sdjoif dfd this should be wrap..."/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.