我有一个包含Table的FlowDocumentScrollViewer,每个表行包含两个包含一些文本的单元格。这是我的xaml。
<FlowDocumentScrollViewer
BorderBrush="Black"
BorderThickness="1"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"
Grid.Row="0"
Grid.Column="0"
VerticalAlignment="Top">
<FlowDocument>
<Table
CellSpacing="1.2">
<Table.Columns>
<TableColumn />
<TableColumn />
</Table.Columns>
<TableRowGroup>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="Instrument Serial Number:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding InstrumentSerialNumber}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="Plate Name:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding PlateName}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="Date of Run:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding DateOfRun}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="User Name of Run Initiator:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding UserName}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="Thermal Cycling Protocol Name:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding ThermalCyclerName}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="Thermal Cycling Definition:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding ThermalCyclerDefinition}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="Bar Code:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding BarCode}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="SuperMix Type:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding SuperMixName}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="Number Of Wells Generated:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding NumberOfWells}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="Number Of Wells Read:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding NumberOfWellsRead}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="Oil Name:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding OilName}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="Total Plate Run Time:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding TotalPlateRunTime}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="Errors:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding Errors}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="Software Version:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding SoftwareVersion}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
<TableRowHelper:BRTableRow>
<TableCell
TextAlignment="Center">
<Paragraph
FontWeight="Bold">
<Run
Text="Firmware Version:"></Run>
</Paragraph>
</TableCell>
<TableCell>
<Paragraph
FontWeight="Bold">
<Run
Text="{Binding FirmwareVersion}"></Run>
</Paragraph>
</TableCell>
</TableRowHelper:BRTableRow>
</TableRowGroup>
</Table>
</FlowDocument>
</FlowDocumentScrollViewer>
请参阅TableRowHelper:BRTableRow这是一个自定义控件,我创建了一个依赖项属性,用于隐藏或显示表行的可见性。这是代码。
public class BRTableRow : TableRow
{
public Visibility IsRowVisible
{
get
{
return (Visibility)GetValue(RowVisibleDependencyProperty);
}
set
{
SetValue(RowVisibleDependencyProperty, value);
}
}
public static readonly DependencyProperty RowVisibleDependencyProperty =
DependencyProperty.Register("IsRowVisible", typeof(Visibility), typeof(BRTableRow), new PropertyMetadata());
}
是否存在可应用于每个表行可见性的通用样式触发器。例如,如果文本是{Binding InstrumentSerialNumber}。如果此文本为空,我想折叠可见性。等等等等。但我不想创造多种风格。我只想要一种可以在所有Table Rows上使用的样式。有任何想法吗。请帮忙。