Preserve white space in content of a object in XAML

By [)ia6l0 iii

If you have additional white spaces in the content of an object, say TextBlock for an example: use the xml:space attribute to preserve space.

The following line would not reserve spaces in the text.
<TextBlock>John Partha          Who is it?</TextBlock>

Use this instead:
<TextBlock xml:space="preserve">John Partha      Who is it?</TextBlock>

If you use the Text Property, you do not need to use the xml attribute. It would work any way.

Related FAQs

Use the DataObject's Pasting handler to avoid pasting text into a textbox
Use the DataObject's Copying handler to avoid copying text from a textbox
Use the Source and the LoadedBehavior properties of the MediaElement.
The following code sample shows you how.
Use the CombinedGeometry class to merge two shapes in WPF
Use the Fill property to fill the object with a specified color.
Preserve white space in content of a object in XAML  (1330 Views)