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>
精彩评论