Figures in a FlowDocument

image_pdfimage_print


   
     
<Window x:Class="Documents.Figures"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="FloatersAndFigures" Height="478" Width="740">
  <Window.Resources>
    <Style x:Key="myStyle">
      <Setter Property="Paragraph.FontSize" Value="30" ></Setter>
      <Setter Property="Paragraph.FontStyle" Value="Italic" ></Setter>
      <Setter Property="Paragraph.Foreground" Value="Green" ></Setter>
      <Setter Property="Paragraph.Padding" Value="5"></Setter>
      <Setter Property="Paragraph.Margin" Value="5,10,15,10"></Setter>
    </Style>
  </Window.Resources>
  <FlowDocumentScrollViewer Name="docViewer" MinZoom="1" MaxZoom="1000" IsToolBarVisible ="True">
    <FlowDocument IsOptimalParagraphEnabled="True" IsHyphenationEnabled="True" >
      <Paragraph>
        text
        <Figure Width="100" Padding="5,0,5,0" HorizontalAnchor="PageRight">
          <BlockUIContainer>
            <Image Source="c:image.jpg" ></Image>
          </BlockUIContainer>
        </Figure>
        text
      </Paragraph>
      <Paragraph>
        The hallway smelt of boiled cabbage and old rag mats.<Run xml:space="preserve"> </Run>
        <Floater Style="{StaticResource myStyle}" Width="205" HorizontalAlignment="Left">
          <Paragraph>this is a test</Paragraph>
        </Floater>
        text
      </Paragraph>
    </FlowDocument>
  </FlowDocumentScrollViewer>

</Window>

   
    
    
    
    
     


Styled Document

image_pdfimage_print


   
     

<Window x:Class="Documents.StyledDocument"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="StyleDocument" Height="500" Width="400">
  <Window.Resources>
    <Style x:Key="Heading">
      <Setter Property="Paragraph.FontSize" Value="30"></Setter>
      <Setter Property="Paragraph.TextDecorations" Value="Underline"></Setter>
      <Setter Property="Paragraph.TextAlignment" Value="Center"></Setter>
    </Style>
    <Style x:Key="Subheading">
      <Setter Property="Paragraph.FontWeight" Value="Bold"></Setter>
      <Setter Property="Paragraph.TextAlignment" Value="Center"></Setter>
    </Style>
  </Window.Resources>

  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition></RowDefinition>
      <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>

    <FlowDocumentScrollViewer>
    <FlowDocument Background="LightYellow" IsOptimalParagraphEnabled="False">

      <Paragraph Style="{StaticResource Heading}" >
        Chapter 1
      </Paragraph>
      <Paragraph Style="{StaticResource Subheading}">
        Part One
      </Paragraph>
      <Paragraph>
        paragraph
      </Paragraph>
      <Paragraph>
        paragraph
      </Paragraph>
    </FlowDocument>
    </FlowDocumentScrollViewer>


  <FlowDocumentScrollViewer Grid.Row="1">
    <FlowDocument Background="LightYellow" IsOptimalParagraphEnabled="True">

      <Paragraph Style="{StaticResource Heading}" >
        Chapter 1
      </Paragraph>
      <Paragraph Style="{StaticResource Subheading}">
        Part One
      </Paragraph>
      <Paragraph>
        paragraph
      </Paragraph>
      <Paragraph>
        paragraph
      </Paragraph>
    </FlowDocument>
  </FlowDocumentScrollViewer>
    
  </Grid>
</Window>

   
    
    
    
    
     


Add ListItem to FlowDocument

image_pdfimage_print


   
     

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  Title="" 
  Height="300" 
  Width="300">
  <Grid>
    <FlowDocumentReader>
      <FlowDocument>
        <List>
          <ListItem><Paragraph>This is a list item.</Paragraph></ListItem>
          <ListItem><Paragraph>This is a list item.</Paragraph></ListItem>
          <ListItem><Paragraph><Bold>This is a bold list item.</Bold></Paragraph></ListItem>
        </List>
      </FlowDocument>
    </FlowDocumentReader>      
  </Grid>
</Window>

   
    
    
    
    
     


FlowDocument with TextAlignment, ColumnWidth. Italic and bold font

image_pdfimage_print


   
      
<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  TextAlignment="Justify" 
  IsOptimalParagraphEnabled="True"
  IsHyphenationEnabled="True"
  IsColumnWidthFlexible="True"
  Background="AliceBlue"
  ColumnWidth="300"
  ColumnGap="20">
  <Paragraph>
    <Italic>italic</Italic>
  </Paragraph>
  <Paragraph>
    <Hyperlink NavigateUri="http://www.yourhost.com">website</Hyperlink>
  </Paragraph>
  <Paragraph>
    <Bold>
      bold
    </Bold>
  </Paragraph>
  <Paragraph>
    <Italic>italic</Italic> or <Italic>italic</Italic>.
  </Paragraph>
</FlowDocument>

   
    
    
    
    
    
     


Flow Document Reader

image_pdfimage_print


   
      

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      Title="title">
    <FlowDocumentReader>
        <FlowDocument>
            <Paragraph TextAlignment="Center" FontSize="16pt">
                 Chapter I
            </Paragraph>
            <Paragraph TextAlignment="Center" FontSize="16pt">
                 Paragraph
            </Paragraph>
            <Paragraph TextIndent="24">
                this is a test
            </Paragraph>
            <Paragraph TextIndent="24">
                this is a test
                this is a test
                this is a test
                this is a test
                this is a test
                this is a test
                this is a test
                this is a test
                this is a test
                this is a test
                this is a test
                this is a test
                this is a test
            </Paragraph>
            <Paragraph TextIndent="24">
                ...
            </Paragraph>
        </FlowDocument>
    </FlowDocumentReader>
</Page>

   
    
    
    
    
    
     


Add FlowDocument to Button

image_pdfimage_print


   
      

<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="FlowDocumentPage" Height="450" Width="500">
    <DockPanel>
        <Button Padding="20" Margin="40">
            <FlowDocumentReader>
                <FlowDocument FontSize="12" xml:space="preserve">
                    <Paragraph TextAlignment="Center" FontSize="18"><Bold>bold</Bold></Paragraph>
                    <Paragraph>Para<Italic>italic</Italic>HTML</Paragraph>
                    <Paragraph>aaa<Button>Push me</Button> 
                    <RadioButton IsChecked="True">Yes</RadioButton>
                    <RadioButton>No</RadioButton>
                    <RadioButton>Unsure</RadioButton>
                    </Paragraph>
                    <Paragraph><Bold>Lists:</Bold></Paragraph>
                    <List>
                        <ListItem><Paragraph>A</Paragraph></ListItem>
                        <ListItem><Paragraph>B</Paragraph></ListItem>
                        <ListItem><Paragraph>C<Ellipse Fill="Red" Width="20" Height="20"/></Paragraph></ListItem>
                        <ListItem><Paragraph>D<Rectangle Fill="Blue" Width="20" Height="20"></Rectangle></Paragraph></ListItem>
                    </List>
                </FlowDocument>
            </FlowDocumentReader>
        </Button>
    </DockPanel>
</Window>

   
    
    
    
    
    
     


FlowDocument with images

image_pdfimage_print


   
      


<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      HorizontalAlignment="Center" VerticalAlignment="Center">

    <FlowDocumentPageViewer>
        <FlowDocument>
          <Paragraph>
            An image in a block container
          </Paragraph>
          <BlockUIContainer>
            <Image Source="c:/Image.jpg" Width="200" />
          </BlockUIContainer>
          <Paragraph>
            An inline UI container:
            <InlineUIContainer BaselineAlignment="Center">
              <Image Source="c:/Image.jpg" Height="40" />
            </InlineUIContainer>
          </Paragraph>
        </FlowDocument>
    </FlowDocumentPageViewer>

</Page>