wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -
Is there a way to format XAM generated when a flow document is saved? Currently, all of this is run simultaneously in one line, and I want to break it into my elements, with line break and indenting it makes it a little easier to read.
Here is the code I'm using to save a FlowDocument in a WPF RichTextBox as a XAML file:
// entire document around TextRange textRange Create a TextRange side = new TextRange (myRichTextBox.Document.ContentStart, myRichTextBox.Document .contentEnd); // save the file using the file (file stream fs = file. Create (filename)) {textRange.Save (fs, DataFormats.Xaml); }
Savings work fine, but as I mentioned, JPAM has been generated, all this goes together, no indentation or line breaks for its various elements Is:
& lt; Section xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml: space = "preserve" Tekstelinement = "left" Lainhait = "auto" Hashipineshn = enabled = "false" xml: lang = "en-us" FlowDirection = "LeftToRight" NumberSubstitution.CultureSource = "text" NumberSubstitution.Substitution = "AsCulture" FontFamily = "Calibri" FontStyle = "normal" FontWeight = "normal" FontStretch = "normal" fONTSIZE = "12" foreground = "# FF000000" Typography.StandardLigatures = "right" Typography.ContextualLigatures = "right" Typography.DiscretionaryLigatures = "false" Typography.HistoricalLigatures = "false" Typography.AnnotationAlternates = "0" Typography.ContextualAlternates = "right" typography. Historical version = "false" typography. Curling = "true" typography. Capital Spacing = "Falls" Typography. Cascency format = "falls" typography. StylistSat 1 = "False" typo graphic. StylistSat2 = "Failus" Typography. StylistSat3 = "False" typography. StylistSat 4 = "False" typography. SilisticSat 5 = "Falls" Typography. Stylistitis = "falls" typography. Stylistic Set 7 = "False" Typography. TalisticSat 8 = "False" Typography StylistSat 9 = "False" Typography StylistSat 10 = "False" typography. StylistSat 11 = "Failus" Typography. Stylistic set 12 = "falls" typography. Stylistic Set 13 = "False" Typography. StylistSat 14 = "False" typography. Sylisticsx = 15 "falls" typography. StylisticSet16 = "False" Typography. Stylistsat 17 = "falls" typography. Stylistic set 18 = "falls" typography. Stylistic Set 1 = "False" Typography. Salicycit 20 = "False" typography. Fracture = "normal" typography. Slashjiro = "False" typography.metametricGeek = "false" typography. East Asian Expert = "Falls" Typography. Version = "normal" typography. Capital = "normal" typography. Normal style = "normal" typography. EnumericElement = "normal" typography. East Asian Wadsiths = "General" Typography. East Asian language = "normal" typography. Standard taste = "0" Typography.ContextualSwashes = "0" Typography.StylisticAlternates = "0" & gt; & Lt; Article NumberSubstitution.CultureSource = "User" FontFamily = "Segoe UI" & gt; & Lt; Run & gt; Lorem ipsum wax ce unaint & lt; / Run & gt; & Lt; / Paragraph & gt; & Lt; / Section & gt;
I have to format XML as a traditional AAMML file, which has line break and indentation for different elements. Is there any way to add formatting to .NET as to generate XAML? Thank you.
A XmlTextWriter
:
(name FileStream FS = File.Create (file) {XmlTextWriter writer = new XmlTextWriter (FS, Encoding.Default); writer.Formatting = Formatting.Indented; textRange.Save ( Second attempt: This is formatting a formatted XML document.
Comments
Post a Comment