相关疑难解决方法(0)

Flowdocument 未使用完整宽度/高度

我有一个 FlowDocument,我想填充窗口的整个宽度和高度。我尝试过使用FlowDocumentPageViewer(没有运气),现在正在使用DocumentPageView. 我仍然无法让它停靠/填满整个空间;它只是坐在中间,以它可以创建的最小尺寸(这有意义吗?)

这是我的代码:

   public DocumentPageView GetPage()
   {
        FlowDocumentPageViewer viewer = new FlowDocumentPageViewer();           
        StreamReader reader = new StreamReader(location);
        string data = reader.ReadToEnd();
        reader.Close();
        string xamlData = HtmlToXamlConverter.ConvertHtmlToXaml(data, true);
        FlowDocument result = (FlowDocument)System.Windows.Markup.XamlReader.Load(new MemoryStream(System.Text.UnicodeEncoding.Default.GetBytes(xamlData)));

        viewer.Document = result;
        viewer.VerticalAlignment = VerticalAlignment.Center;
        viewer.HorizontalAlignment = HorizontalAlignment.Center;

        DocumentPageView pageView = new DocumentPageView();
        pageView.VerticalAlignment = VerticalAlignment.Center;
        pageView.HorizontalAlignment = HorizontalAlignment.Center;
        pageView.Stretch = System.Windows.Media.Stretch.Uniform;
        pageView.PageNumber = 0;
        pageView.StretchDirection = StretchDirection.Both;
        pageView.DocumentPaginator = ((IDocumentPaginatorSource)result).DocumentPaginator;
        return pageView;
   }
Run Code Online (Sandbox Code Playgroud)

请注意,此代码包含我的两种方法的组合,但DocumentPageView当前仅使用。这是从我的 HTML 源创建的 Xaml:

<FlowDocument xml:space="preserve" …
Run Code Online (Sandbox Code Playgroud)

wpf resize flowdocument

3
推荐指数
1
解决办法
8973
查看次数

如何设置WPF FlowDocument的原始宽度

我有这个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*" …
Run Code Online (Sandbox Code Playgroud)

wpf xaml flowdocument

3
推荐指数
2
解决办法
8071
查看次数

标签 统计

flowdocument ×2

wpf ×2

resize ×1

xaml ×1