2

ドキュメントを使用してユーザー コントロールを表示しています。ここの何人かが私を助けてくれました:ドキュメント ビューアー内にユーザー コントロールを配置するにはどうすればよいですか?

しかし、ユーザーコントロールは隅に表示されます。印刷したいのですが、もう少し中央に配置します。

4

1 に答える 1

4

他の質問から私の更新された答えを繰り返します。

Width/HeightをFixedPageActualWidth/ ActualHeightにバインドするにを配置して、センタリングを実現できUserControlますGrid

<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>
于 2011-08-13T01:50:55.230 に答える