我有这个XAML结构:
<wft:Dialog x:Class="WFT.PumpSvc.Bench.Parts.PartsPullListDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:wft="http://schemas.Weatherford.com">
<wft:Dialog.Resources>
<ResourceDictionary Source="../Resources.xaml" />
</wft:Dialog.Resources>
<wft:CaptionedBox Style="{StaticResource HeaderCaptionedBox}" Name="captionedBox" Caption="Parts Pull List">
<DockPanel>
<DockPanel DockPanel.Dock="Right">
<StackPanel Orientation="Vertical" DockPanel.Dock="Top">
<wft:TouchButton Name="closeButton">Cancel</wft:TouchButton>
</StackPanel>
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom">
<wft:TouchButton Name="printButton">Print</wft:TouchButton>
</StackPanel>
</DockPanel>
<wft:CaptionedBox Caption="Preview">
<FlowDocumentPageViewer Name="documentReader">
<FlowDocument Background="White">
<Paragraph FontSize="20" FontWeight="Bold">Parts Pull List</Paragraph>
<Table FontWeight="Bold">
<Table.Columns>
<TableColumn Width="*" />
<TableColumn Width="2*" />
</Table.Columns>
<TableRowGroup>
<TableRow>
<TableCell>...
<TableCell>...
</TableRow>
<TableRow>...
<TableRow>...
</TableRowGroup>
</Table>
<Table>
<Table.Columns>
<TableColumn Width="1*" />
<TableColumn Width="1*" />
<TableColumn Width="1*" />
<TableColumn Width="1*" />
<TableColumn Width="1*" />
<TableColumn Width="1*" />
<TableColumn Width="1*" />
</Table.Columns>
<TableRowGroup Name="partRowGroup">
<TableRow>
<TableCell>
<Paragraph>
<Underline>SubAssembly Type</Underline>
</Paragraph>
</TableCell>
<TableCell>...
<TableCell>...
<TableCell>...
<TableCell>...
<TableCell>...
<TableCell>...
</TableRow>
</TableRowGroup>
</Table>
</FlowDocument>
</FlowDocumentPageViewer>
</wft:CaptionedBox>
</DockPanel>
</wft:CaptionedBox>
</wft:Dialog>
如您所见,我的页面上没有任何宽度设置。但是,我的表只占FlowDocument中水平空间的一半。是什么控制了这个?
答案 0 :(得分:17)
设置FlowDocument ColumnWidth =“999999”
答案 1 :(得分:6)
FlowDocument对象支持您在PageWidth,PagePadding属性中查找的功能。 ColumnWidth属性不会影响页面宽度,而是建议或可以强制执行如何在页面宽度的范围内布置列。
博客中有关此主题的更多详情:
PageWidth :这表示文档页面的宽度。该量设置在与设备无关的像素中(像素是1/96英寸,因此1“= 96像素)。请记住,在设置此值时,还必须考虑页边距。
PagePadding :这个名称,更适合WPF然后在文档中,实际上是页边距。纸张边缘与内容之间的像素数量(1/96英寸)。所以基本上,PagePadding + PageWidth应该等于或至少不大于纸张宽度。如果你有8.5英寸宽的纸张(816像素)并且你有1/2边距(48像素* 2 = 96)那么你只有720像素可以用于PageWidth。 PagePadding属于类型厚度,因此您可以设置适用于所有边距的统一值,或者根据需要单独设置每个边距。
ColumnWidth :这个与容器的大小无关,就像容器中的内容的布局方式一样。如名称所示,它设置文档列的所需宽度。它只是 desired ,因为默认情况下,布局会调整ColumnWidth以充分利用页面的可用宽度。要强制执行列宽设置,您需要设置IsColumnWidthFlexible = False。
答案 2 :(得分:0)
FlowDocument.ColumnWidth属性http://msdn.microsoft.com/en-us/library/system.windows.documents.flowdocument.columnwidth(v=vs.85).aspx上的一些社区内容显示“默认情况下,Flow Document的列宽是字体大小的20倍”。我将FontSize =“40”添加到FlowDocument并获得了我可以使用的宽度。我只需要在其他地方提供FontSizes,因为我真的不想要40。