如何在文档查看器中居中放置页面? [英] How can I center my page in the document viewer?

查看:102
本文介绍了如何在文档查看器中居中放置页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用文档来显示用户控件.来自这里的一些人帮助了我:如何将用户控件放在文档查看器中?

I'm using a document to show a user control. Some people from here helped me: How can I put an user control inside a document viewer?

但是用户控件会出现在角落,我想打印出来,但是要集中一些.

But the user control appers in the corner, and I'd like to print it, but a little bit more central.

推荐答案

从另一个问题重复我更新的答案.

Repeating my updated answer from the other question..

您可以将UserControl放在Grid中,该宽度将其宽度/高度绑定到FixedPage ActualWidth/ActualHeight以实现居中

You can place the UserControl in a Grid which binds its Width/Height to the FixedPage ActualWidth/ActualHeight to achieve centering

<DocumentViewer>
    <FixedDocument>
        <PageContent>
            <FixedPage>
                <Grid Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type FixedPage}},
                                      Path=ActualWidth}"
                      Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type FixedPage}},
                                       Path=ActualHeight}">
                    <local:MyUserControl HorizontalAlignment="Center"
                                         VerticalAlignment="Center"/>
                </Grid>
            </FixedPage>
        </PageContent>
    </FixedDocument>
</DocumentViewer>

这篇关于如何在文档查看器中居中放置页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆