I am using a TextBlock in WPF, on which I want to use TextWrapping, What I have done in XAML is as follows.
<TextBlock TextWrapping="Wrap" Grid.Column="0" Grid.ColumnSpan="4" Grid.Row="0" Margin="5,5,5,5">
<TextBlock.Text>
This is just a test. This is just a test.
</TextBlock.Text>
</TextBlock>
When I run this code it shows output like this
This is just a test. Th
is is just a test.
But I only want wrapping on white spaces like
This is just a test.
This is just a test.
I am unable to find why WPF is showing this behavior, I have tried WrapWithOverflow
and IsHyphenationEnabled=true
with no success. Please help me out?
Bizz is right, this shouldn't be the behavior of Text Wrapping, Just a wild guess, are you copy/pasting text from some where to Visual studio? there might be an issue with white spaces in that case, and WPF will wrap your text in wrong way.
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.