Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF打印流程文件不居中_Wpf_Printing_Alignment_Center_Flowdocument - Fatal编程技术网

WPF打印流程文件不居中

WPF打印流程文件不居中,wpf,printing,alignment,center,flowdocument,Wpf,Printing,Alignment,Center,Flowdocument,我想打印一页从一些文本,我有一个小标题。 我想把所有的文字都放在页面的中心,但我不知道怎么做 这是我的密码。。t是track类型,它只是一个保存艺术家姓名、专辑名称、歌曲标题和歌词等信息的对象 PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog() != true) { return; } FlowDocument doc = new FlowDocu

我想打印一页从一些文本,我有一个小标题。 我想把所有的文字都放在页面的中心,但我不知道怎么做

这是我的密码。。t是track类型,它只是一个保存艺术家姓名、专辑名称、歌曲标题和歌词等信息的对象

 PrintDialog dialog = new PrintDialog();
            if (dialog.ShowDialog() != true)
            { return; }
            FlowDocument doc = new FlowDocument();
            Section sec = new Section();
            Paragraph header = new Paragraph();
            Paragraph body = new Paragraph();
            Bold boldSong = new Bold();
            boldSong.Inlines.Add(new Run(t.Song));
            header.Inlines.Add(boldSong);
            header.Inlines.Add(new LineBreak());
            Bold boldArtist = new Bold();
            if (!string.IsNullOrWhiteSpace(t.Artist))
            {
                boldArtist.Inlines.Add(new Run(t.Artist));
                header.Inlines.Add(boldArtist);
                header.Inlines.Add(new LineBreak());
            }
            Bold boldAlbum = new Bold();
            if (!string.IsNullOrWhiteSpace(t.Album))
            {
                boldAlbum.Inlines.Add(new Run(t.Album));
                header.Inlines.Add(boldAlbum);
                header.Inlines.Add(new LineBreak());
            }
            header.TextAlignment = TextAlignment.Center;
            body.Inlines.Add(t.iTunesFileTrack.Lyrics);
            body.TextAlignment = TextAlignment.Center;
            doc.Blocks.Add(header);
            doc.Blocks.Add(body);
            doc.Name = "FlowDoc";
            IDocumentPaginatorSource idpSource = doc;
            DocumentPaginator holder = idpSource.DocumentPaginator;
            holder.PageSize = new Size(dialog.PrintableAreaWidth,
        dialog.PrintableAreaHeight);
            dialog.PrintDocument(holder, "Lyrics");

这一页打印得很好,只是打印时整个页面都贴在文档的左边。。。我知道有些属性设置不正确或根本没有设置

增大ColumnWidth属性的大小或仅将其设置为“999999”

增大ColumnWidth属性的大小或仅将其设置为“999999”