| |
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 |
|