开发者

How can I center my page in the document viewer?

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 appe开发者_高级运维rs in the corner, and I'd like to print it, but a little bit more central.


Repeating my updated answer from the other question..

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>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜