DataGrid display indented XML in column

How can I display indented, i.e. prettified XML in a DataGrid column?

Hi @Blaze,

You can try combining the approach from here: with a <pre> element used in the Template of a column:


Or if using Radzen set the Template property of the column to:


Add the PrintXML method to the partial class of your page (xxx.razor.cs)

1 Like

That works but now it is centered by default so I added "TextAlign="TextAlign.Left"" to the column but it has no effect. It also has no effect on other columns.

Please share the code snippet here

Check the alignment by inspecting the <pre> with your Browser's developer tools. By the default all text is left aligned so it is probably the leading whitespace that makes it look centered.