0

I have this WPF window contents with FlowDocumentReader inside:

<Window x:Class="KopiranjeProekti.UpatstvoZaKoristenjeWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:KopiranjeProekti"
        mc:Ignorable="d"
        Title="Упатство за Користење" Height="450" Width="800" Closing="Window_Closing">
    <Grid>
        <FlowDocumentReader Grid.Row="1" BorderBrush="Navy" BorderThickness="2" Name="flowReader">
            <FlowDocument
                Name="flowDoc"
                TextAlignment="Justify" 
                IsOptimalParagraphEnabled="True"
                IsHyphenationEnabled="True"
                IsColumnWidthFlexible="True"
                Background="AliceBlue"
                ColumnWidth="300"
                ColumnGap="20">
                <Paragraph>
                    1. Ова е софтвер за копирање на постоечки проекти(папки) и целокупната нивна содржина.
                    На Виндоус 10 некои фајлови прават пречка за копирање, како на пример *.OCX(ActiveX компонента),
                    засебни *.EXE извршни фајлови. Затоа пожелно е фајловите кои се добиваат како извод на компајлирање
                    или се некакви засебни компоненти или извршни датотеки, да се чуваат надвор од папката која треба да 
                    се ископира со нејзината содржина. 
                </Paragraph>
                <Paragraph>
                        2. За да се користи апликаcијата потребно е на дискот C: да се створи папка која ќе се вика KopiranjeProekti
                    и во нејзе да се сними фајл Proekti.xml кој ќе има содржина налик на следнава:ж    
                </Paragraph>
                <Paragraph>
                    &lt;?xml version="1.0" encoding="utf-8" ?&gt;
                    &lt;proekti&gt;
  
                      &lt;sektorskiPateka&gt;sektorski disk pateka&lt;/sektorskiPateka&gt;
                      &lt;nasPateka&gt;Network Access Storage(NAS) disk&lt;/nasPateka&gt;
                      &lt;spodeluvanjePateka&gt;pateka za spodeluvanje so kolegi&lt;/spodeluvanjePateka&gt;
                      &lt;mcafeeServerPateka&gt;pateka na kompjuter kade se arhiviraat aplikaciite&lt;/mcafeeServerPateka&gt;
  
                      &lt;proekt&gt;
                        &lt;ime&gt;WpfExercise1&lt;/ime&gt;
                        &lt;pateka&gt;C:\Users\vlzak\Documents\c_sharp_vezhbi\WpfExercise1&lt;/pateka&gt;
                      &lt;/proekt&gt;
  
                    &lt;/proekti&gt;
                </Paragraph>
            </FlowDocument>
        </FlowDocumentReader>
    </Grid>
</Window>

AS you can see, I am trying to explain a contents of a given XML documents inside the FlowDocumentReader. Though it works and it compiles, I see the window like this:

WPF XML inside FlowDocumentReader

What is the right way to display XML inside WPF FlowDocumentReader, but I want it properly indented, and not in two columns?

EDIT: I found a tag, its called , for FlowDocumentReader which you put in the text where a line break should appear in a tag. The only thing i couldn't figure out is how to indent a line of text in a paragraph tag. Yes you can indent the paragraph itself but you cannot put paragraph in a paragraph tag. You can wrap text in a span tag inside a paragraph tag, but not sure what to do with it.

Community
  • 1
  • 1
Vlad
  • 2,739
  • 7
  • 49
  • 100

1 Answers1

0

One of the overloads of Inlines accepts a string. You can get pretty-indented XML with XElement (assuming Paragraph has name par):

var xml_string = 
    @"<?xml version='1.0' encoding='utf-8'?>
        <proekti>
            <sektorskiPateka>sektorski disk</sektorskiPateka>
            <naspateka>Network Access Storage (NAS) disk</naspateka>
        </proekti>";
var xml = XElement.Parse(xml_string);
par.Inlines.Add(xml.ToString());
JohnyL
  • 6,894
  • 3
  • 22
  • 41
  • Nop. I found a tag, its called , for FlowDocumentReader which you put in the text where a line break should appear in a tag. The only thing i couldn't figure out is how to indent a line of text in a paragraph tag. Yes you can indent the paragraph itself but you cannot put paragraph in a paragraph tag. You can wrap text in a span tag inside a paragraph tag, but not sure what to do with it. – Vlad Jan 09 '20 at 21:38