I start a new WPF Application and paste following code to the MainWindow.xaml
<Canvas>
<TextBlock Text="Kammer 123"
MaxWidth="80"
Padding="5, 0"
TextWrapping="Wrap"
TextAlignment="Center" />
</Canvas>
The expected result is a TextBlock rendering “Kammer 123” in the upper left corner, but what I see is only “Kammer”. If I change the Text property to “Kammer 1234” or “Kammer 12” or “Kammer abc” the rendering is correct. With “Kammer 12345” the text is wrapped correctly. Is this a bug or a feature I do not understand?
Very interesting bug! I can confirm your results. On Windows XP 32-bit at 96 dpi, the “123” gets cut off but other sequences render correctly. On Windows 7 64-bit at 120 dpi, all strings render correctly. So that’s indeed a WPF text layout bug, either for 96 dpi or on 32 bit.
Some experimentation shows that the Padding line is the culprit. Remove that line or reduce horizontal padding to 1, and the text shows up correctly. An alternative would be to use Margin instead of Padding, that seems to work.