Table Flow Content : FlowDocument « Windows Presentation Foundation « C# / C Sharp






Table Flow Content

Table Flow Content
  
<Window x:Class="Documents.FlowContent"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="FlowContent" Height="400" Width="600">

    <FlowDocumentScrollViewer Name="docViewer" IsToolBarVisible="True" >
    <FlowDocument>      
      <BlockUIContainer>
        <Button Click="cmdCreateDynamicDocument_Click" HorizontalAlignment="Left" Padding="5">Create a Dynamic Document</Button>
      </BlockUIContainer>
      <Paragraph FontSize="20pt">Largest Cities in the Year 100</Paragraph>
      <Table>
        <Table.Columns>
          <TableColumn Width="*"></TableColumn>
          <TableColumn Width="3*"></TableColumn>
          <TableColumn Width="*"></TableColumn>
        </Table.Columns>

        <TableRowGroup  >
          <TableRow FontWeight="Bold" >
            <TableCell >
              <Paragraph>Title 1</Paragraph>
            </TableCell>
            <TableCell>
              <Paragraph>Title 2</Paragraph>
            </TableCell>
            <TableCell>
              <Paragraph>Title 3</Paragraph>
            </TableCell>
          </TableRow>
          <TableRow>
            <TableCell>
              <Paragraph>A</Paragraph>
            </TableCell>
            <TableCell>
              <Paragraph>A</Paragraph>
            </TableCell>
            <TableCell>
              <Paragraph>A</Paragraph>
            </TableCell>
          </TableRow>
        </TableRowGroup>
      </Table>
    </FlowDocument>
  </FlowDocumentScrollViewer>

</Window>

//File:Window.xaml.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Documents
{
    public partial class FlowContent : System.Windows.Window
    {
        public FlowContent()
        {
            InitializeComponent();           
        }
        private void cmdCreateDynamicDocument_Click(object sender, RoutedEventArgs e)
        {
            Run runFirst = new Run();
            runFirst.Text = "A ";

            Bold bold = new Bold();
            Run runBold = new Run();
            runBold.Text = "bold ";
            bold.Inlines.Add(runBold);

            Run runLast = new Run();
            runLast.Text = " documents";

            Paragraph paragraph = new Paragraph();
            paragraph.Inlines.Add(runFirst);
            paragraph.Inlines.Add(bold);
            paragraph.Inlines.Add(runLast);

            FlowDocument document = new FlowDocument();
            document.Blocks.Add(paragraph);

            docViewer.Document = document;
        }
    }
}

   
    
  








Related examples in the same category

1.FlowDocument with SectionFlowDocument with Section
2.FlowDocument with UI containerFlowDocument with UI container
3.FlowDocument with TableFlowDocument with Table
4.Span and FlowDoucmentSpan and FlowDoucment
5.FlowDocument with Figure.xamlFlowDocument with Figure.xaml
6.Paragraph FontWeightParagraph FontWeight
7.FlowDocument with Hyperlink and ListFlowDocument with Hyperlink and List
8.Adding style to ParagraphAdding style to Paragraph
9.Bold text in Flow documentBold text in Flow document
10.Create Table layout in FlowDocument
11.Figures in a FlowDocumentFigures in a FlowDocument
12.Styled DocumentStyled Document
13.Add ListItem to FlowDocumentAdd ListItem to FlowDocument
14.FlowDocument with TextAlignment, ColumnWidth. Italic and bold fontFlowDocument with TextAlignment, ColumnWidth. Italic and bold font
15.Flow Document ReaderFlow Document Reader
16.Add FlowDocument to ButtonAdd FlowDocument to Button
17.FlowDocument with imagesFlowDocument with images
18.Add Shape(Ellipse, Rectangle) to ListAdd Shape(Ellipse, Rectangle) to List
19.Change FlowDocument Width and HeightChange FlowDocument Width and Height
20.Programmatically change the FlowDirection of content within a FlowDocumentReader elementProgrammatically change the FlowDirection of content within a FlowDocumentReader element
21.Use FlowDocumentReader to display FlowDocumentUse FlowDocumentReader to display FlowDocument
22.Programmatically Create and Save a FlowDocumentProgrammatically Create and Save a FlowDocument
23.Use XamlDesignerSerializationManager to write FlowDocumentUse XamlDesignerSerializationManager to write FlowDocument
24.Show FlowDocumentShow FlowDocument
25.Load a FlowDocument into a FlowDocumentReader,Load a FlowDocument into a FlowDocumentReader,
26.Convert Xaml file to FlowDocument with as operator
27.Save a FlowDocument as a Extensible Application Markup Language (XAML) file
28.Clear FlowDocumentReaderClear FlowDocumentReader
29.Programmatically add rows to a Table element.Programmatically add rows to a Table element.
30.Annotation ServiceAnnotation Service
31.Toggle Hyphenation, Optimal Paragraph, and Column FlexToggle Hyphenation, Optimal Paragraph, and Column Flex
32.Change font Change font