Line break in data grid header


I need a line break in a data grid header because I want Title="Current [A]" to be displayed as

I do not want to trigger the line break with a specific column width. So, I tried Title="Current\n[A]" what resulted in

Next I tried, defining a string variable private string titleCurrent = "Current\n[A]"; and Title="@titleCurrent " what resulted in
Current [A]
So, the \n was interpreted as space.

private string titleCurrent = Convert.ToString((MarkupString)("Current<br />[A]")); also did not work, but delivered
Current<br />[A]

What is the correct way to get a line break?



New line symbols aren't normally displayed as a new line in HTML. You either need to use a <br> or apply CSS white-space: pre styling to a wrapper HTML element. You can do so via the HeaderTemplate of the column:

        <span style="white-space: pre">

Or with a <br>:


Nice! Thanks.
Is there also a way to set the width of the column to auto? Width="auto" does not work.

If you are looking for automatic width - this isn't supported. You either set the Width in some unit or omit the Width property.

Omitting the Width property is not an option for me, because then all columns have the same width.
I can set each column Width property but please consider Width="auto" as a feature request because changing the font (size, weight) makes me change all the widths again.