<Window x:Class="DataGrid.Window4"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window4" Height="300" Width="980">
<Window.Resources>
<SolidColorBrush x:Key="ProductNameBackgroundBrush" Color="#87B7FF" />
<SolidColorBrush x:Key="SubjectAreaBackgroundBrush" Color="#D99795" />
<SolidColorBrush x:Key="ExceptionHeaderBackgroundBrush" Color="#E6B9B8" />
<SolidColorBrush x:Key="ExceptionCellBackgroundBrush" Color="#F2DDDC" />
<Style x:Key="ProductNameStyle" TargetType="{x:Type TableCell}">
<Setter Property="Background" Value="{StaticResource ProductNameBackgroundBrush}" />
<Setter Property="FontFamily" Value="Trebuchet MS" />
<Setter Property="FontWeight" Value="Light" />
<Setter Property="FontSize" Value="12" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="3,18" />
<Setter Property="Cursor" Value="Arrow" />
<Setter Property="TextAlignment" Value="Center" />
</Style>
<Style x:Key="ProductNameStyle2" TargetType="{x:Type TableCell}">
<Setter Property="Background" Value="{StaticResource ProductNameBackgroundBrush}" />
<Setter Property="FontFamily" Value="Trebuchet MS" />
<Setter Property="FontWeight" Value="Light" />
<Setter Property="FontSize" Value="12" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Cursor" Value="Arrow" />
<Setter Property="Padding" Value="3,6" />
<Setter Property="TextAlignment" Value="Center" />
</Style>
<Style x:Key="SubjectAreaStyle" TargetType="{x:Type TableCell}">
<Setter Property="Background" Value="{StaticResource SubjectAreaBackgroundBrush}" />
<Setter Property="FontFamily" Value="Trebuchet MS" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontSize" Value="15" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="3,6,0,6" />
</Style>
<Style x:Key="ExceptionHeaderStyle" TargetType="{x:Type TableCell}">
<Setter Property="Background" Value="{StaticResource ExceptionHeaderBackgroundBrush}" />
<Setter Property="FontFamily" Value="Trebuchet MS" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontSize" Value="15" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="3,6,0,6" />
</Style>
<Style x:Key="ExceptionCellStyle" TargetType="{x:Type TableCell}">
<Setter Property="Background" Value="{StaticResource ExceptionCellBackgroundBrush}" />
<Setter Property="FontFamily" Value="Trebuchet MS" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontSize" Value="12" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="3,6,0,6" />
</Style>
</Window.Resources>
<Grid SnapsToDevicePixels="True">
<FlowDocumentScrollViewer SnapsToDevicePixels="True" VerticalScrollBarVisibility="Disabled" Cursor="Arrow">
<FlowDocument ColumnWidth="40" FontSize="14" FontFamily="Georgia">
<Table Background="Black" CellSpacing="1" BorderThickness="1" BorderBrush="Black" >
<TableRowGroup>
<TableRow >
<TableCell ColumnSpan="1" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Padding="0,18,0,0" Style="{StaticResource ProductNameStyle}">
<Paragraph>
XX
</Paragraph>
</TableCell>
<TableCell ColumnSpan="4" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Paragraph>
XXX
</Paragraph>
</TableCell>
<TableCell ColumnSpan="4" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Paragraph>
XXXX
</Paragraph>
</TableCell>
<TableCell ColumnSpan="6" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Paragraph>
XXXXX
</Paragraph>
</TableCell>
<TableCell Padding="0" ColumnSpan="10" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Table Margin="0" Background="Black" CellSpacing="1" BorderThickness="0" BorderBrush="Red" >
<TableRowGroup>
<TableRow >
<TableCell ColumnSpan="5" BorderThickness="0" Style="{StaticResource ProductNameStyle2}">
<Paragraph> CCCCCCC</Paragraph>
</TableCell>
</TableRow>
<TableRow >
<TableCell BorderThickness="0" Style="{StaticResource ProductNameStyle2}">
<Paragraph>ZZZZZZ</Paragraph>
</TableCell>
<TableCell BorderThickness="0" Style="{StaticResource ProductNameStyle2}">
<Paragraph>XXX</Paragraph>
</TableCell>
<TableCell BorderThickness="0" Style="{StaticResource ProductNameStyle2}">
<Paragraph>XXX</Paragraph>
</TableCell>
<TableCell BorderThickness="0" Style="{StaticResource ProductNameStyle2}">
<Paragraph>XXX</Paragraph>
</TableCell>
<TableCell BorderThickness="0" Style="{StaticResource ProductNameStyle2}">
<Paragraph>XXX</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
</TableCell>
<TableCell ColumnSpan="5" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Paragraph>
XXXXXX
</Paragraph>
</TableCell>
</TableRow>
<TableRow >
<TableCell ColumnSpan="1" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Paragraph>
XXXXXXXX
</Paragraph>
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="4" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="4" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="6" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="5" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
</FlowDocument>
</FlowDocumentScrollViewer>
<!--FlowDocumentScrollViewer VerticalScrollBarVisibility="Disabled">
<FlowDocument>
<Table CellSpacing="1" Background="Black" BorderThickness="1" BorderBrush="Black" >
<TableRowGroup>
<TableRow >
<TableCell ColumnSpan="3" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Table>
</Table>
</TableCell>
</TableRow>
<TableRow >
<TableCell BorderThickness="0" Style="{StaticResource ExceptionCellStyle}" >
<Paragraph>Field 3</Paragraph>
</TableCell>
<TableCell BorderThickness="0" Style="{StaticResource ExceptionCellStyle}">
<Paragraph>Missing Data</Paragraph>
</TableCell>
<TableCell BorderThickness="0" Style="{StaticResource ExceptionCellStyle}">
<Paragraph>Enter information</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
</FlowDocument>
</FlowDocumentScrollViewer-->
</Grid>
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window4" Height="300" Width="980">
<Window.Resources>
<SolidColorBrush x:Key="ProductNameBackgroundBrush" Color="#87B7FF" />
<SolidColorBrush x:Key="SubjectAreaBackgroundBrush" Color="#D99795" />
<SolidColorBrush x:Key="ExceptionHeaderBackgroundBrush" Color="#E6B9B8" />
<SolidColorBrush x:Key="ExceptionCellBackgroundBrush" Color="#F2DDDC" />
<Style x:Key="ProductNameStyle" TargetType="{x:Type TableCell}">
<Setter Property="Background" Value="{StaticResource ProductNameBackgroundBrush}" />
<Setter Property="FontFamily" Value="Trebuchet MS" />
<Setter Property="FontWeight" Value="Light" />
<Setter Property="FontSize" Value="12" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="3,18" />
<Setter Property="Cursor" Value="Arrow" />
<Setter Property="TextAlignment" Value="Center" />
</Style>
<Style x:Key="ProductNameStyle2" TargetType="{x:Type TableCell}">
<Setter Property="Background" Value="{StaticResource ProductNameBackgroundBrush}" />
<Setter Property="FontFamily" Value="Trebuchet MS" />
<Setter Property="FontWeight" Value="Light" />
<Setter Property="FontSize" Value="12" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Cursor" Value="Arrow" />
<Setter Property="Padding" Value="3,6" />
<Setter Property="TextAlignment" Value="Center" />
</Style>
<Style x:Key="SubjectAreaStyle" TargetType="{x:Type TableCell}">
<Setter Property="Background" Value="{StaticResource SubjectAreaBackgroundBrush}" />
<Setter Property="FontFamily" Value="Trebuchet MS" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontSize" Value="15" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="3,6,0,6" />
</Style>
<Style x:Key="ExceptionHeaderStyle" TargetType="{x:Type TableCell}">
<Setter Property="Background" Value="{StaticResource ExceptionHeaderBackgroundBrush}" />
<Setter Property="FontFamily" Value="Trebuchet MS" />
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontSize" Value="15" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="3,6,0,6" />
</Style>
<Style x:Key="ExceptionCellStyle" TargetType="{x:Type TableCell}">
<Setter Property="Background" Value="{StaticResource ExceptionCellBackgroundBrush}" />
<Setter Property="FontFamily" Value="Trebuchet MS" />
<Setter Property="FontWeight" Value="Normal" />
<Setter Property="FontSize" Value="12" />
<Setter Property="BorderBrush" Value="Black" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="3,6,0,6" />
</Style>
</Window.Resources>
<Grid SnapsToDevicePixels="True">
<FlowDocumentScrollViewer SnapsToDevicePixels="True" VerticalScrollBarVisibility="Disabled" Cursor="Arrow">
<FlowDocument ColumnWidth="40" FontSize="14" FontFamily="Georgia">
<Table Background="Black" CellSpacing="1" BorderThickness="1" BorderBrush="Black" >
<TableRowGroup>
<TableRow >
<TableCell ColumnSpan="1" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Padding="0,18,0,0" Style="{StaticResource ProductNameStyle}">
<Paragraph>
XX
</Paragraph>
</TableCell>
<TableCell ColumnSpan="4" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Paragraph>
XXX
</Paragraph>
</TableCell>
<TableCell ColumnSpan="4" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Paragraph>
XXXX
</Paragraph>
</TableCell>
<TableCell ColumnSpan="6" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Paragraph>
XXXXX
</Paragraph>
</TableCell>
<TableCell Padding="0" ColumnSpan="10" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Table Margin="0" Background="Black" CellSpacing="1" BorderThickness="0" BorderBrush="Red" >
<TableRowGroup>
<TableRow >
<TableCell ColumnSpan="5" BorderThickness="0" Style="{StaticResource ProductNameStyle2}">
<Paragraph> CCCCCCC</Paragraph>
</TableCell>
</TableRow>
<TableRow >
<TableCell BorderThickness="0" Style="{StaticResource ProductNameStyle2}">
<Paragraph>ZZZZZZ</Paragraph>
</TableCell>
<TableCell BorderThickness="0" Style="{StaticResource ProductNameStyle2}">
<Paragraph>XXX</Paragraph>
</TableCell>
<TableCell BorderThickness="0" Style="{StaticResource ProductNameStyle2}">
<Paragraph>XXX</Paragraph>
</TableCell>
<TableCell BorderThickness="0" Style="{StaticResource ProductNameStyle2}">
<Paragraph>XXX</Paragraph>
</TableCell>
<TableCell BorderThickness="0" Style="{StaticResource ProductNameStyle2}">
<Paragraph>XXX</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
</TableCell>
<TableCell ColumnSpan="5" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Paragraph>
XXXXXX
</Paragraph>
</TableCell>
</TableRow>
<TableRow >
<TableCell ColumnSpan="1" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Paragraph>
XXXXXXXX
</Paragraph>
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="4" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="4" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="6" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="2" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
<TableCell ColumnSpan="5" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
</FlowDocument>
</FlowDocumentScrollViewer>
<!--FlowDocumentScrollViewer VerticalScrollBarVisibility="Disabled">
<FlowDocument>
<Table CellSpacing="1" Background="Black" BorderThickness="1" BorderBrush="Black" >
<TableRowGroup>
<TableRow >
<TableCell ColumnSpan="3" BorderThickness="0" Style="{StaticResource ProductNameStyle}">
<Table>
</Table>
</TableCell>
</TableRow>
<TableRow >
<TableCell BorderThickness="0" Style="{StaticResource ExceptionCellStyle}" >
<Paragraph>Field 3</Paragraph>
</TableCell>
<TableCell BorderThickness="0" Style="{StaticResource ExceptionCellStyle}">
<Paragraph>Missing Data</Paragraph>
</TableCell>
<TableCell BorderThickness="0" Style="{StaticResource ExceptionCellStyle}">
<Paragraph>Enter information</Paragraph>
</TableCell>
</TableRow>
</TableRowGroup>
</Table>
</FlowDocument>
</FlowDocumentScrollViewer-->
</Grid>
</Window>
HTML Like table Creation in WPF
http://weblogs.asp.net/kashyapa/archive/2010/01/11/html-like-table-creation-in-wpf.aspx
下载地址:点击打开链接