Home > Net >  Remove border and shadow from DocumentViewer in WPF
Remove border and shadow from DocumentViewer in WPF

Time:11-14

Good evening. I have been chasing an issue with DocumentViewer and don't know how to address it.

When you display a document in a DocumentViewer control, it displays a border and a shadow around the document and I do not know how to get rid of it.

I have written a control template, which I would have expected to have addressed the issue and it does not. Here it is:

  <Style x:Key="MyDocStyle" TargetType="DocumentViewer">
     <Setter Property="Template">
        <Setter.Value>
           <ControlTemplate TargetType="DocumentViewer">
              <Border BorderThickness="5" >
              <Grid>
                 <ScrollViewer HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" x:Name="PART_ContentHost"
                               Background="Transparent"
                 BorderBrush="Transparent" BorderThickness="0" Padding="0" >
                 </ScrollViewer>
              </Grid>
              </Border>
           </ControlTemplate>
        </Setter.Value>
     </Setter>
  </Style>

What else am I missing? Thank you in advance.

CodePudding user response:

Turns out, you don't need to alter the ControlTemplate at all. May I point out DocumentViewer.ShowPageBorders:

Indicates whether drop-shadow page borders are displayed

Usage:

<DocumentViewer ShowPageBorders="False"/>

CodePudding user response:

Thank you very much. I'm not sure how I missed that. Nonetheless, thank you very much for your help!

  • Related