This is a migrated thread and some comments may be shown as answers.

How to remove the grey background from pdf viewer

5 Answers 698 Views
PDFViewer
This is a migrated thread and some comments may be shown as answers.
Mohammad
Top achievements
Rank 1
Mohammad asked on 22 May 2012, 08:49 AM
Hi,
q1 : I want to remove the grey background from the pdfviewer (for making a style)?

Is there a way to do this?

thanks

5 Answers, 1 is accepted

Sort by
0
Lancelot
Top achievements
Rank 1
answered on 23 May 2012, 11:59 PM
Hi Mohammad,

All you need to do to change the background of a RadPDF viewer is create a new static resource template for the PDFviewer control. In the template, locate the root grid and add a background property. Select what color you want it to be here.

I've written you an example that you can copy and paste into a new project. I've changed the background to black.
<Window x:Class="PDFviewerExample.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
                Title="MainWindow" Height="350" Width="525">
    <Window.Resources>
        <telerik:Office_BlackTheme x:Key="Theme"/>
        <ControlTemplate x:Key="FixedDocumentViewerBaseTemplate" TargetType="telerik:RadPdfViewer">
     <!-- HERE is where you can alter the root background color -->
            <Grid Background="Black">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <Grid Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <ContentControl x:Name="PART_ContentPresenter" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" VerticalAlignment="Stretch" VerticalContentAlignment="Stretch"/>
                    <ScrollBar x:Name="PART_VerticalScrollBar" Grid.Column="1" Orientation="Vertical" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="Collapsed"/>
                    <ScrollBar x:Name="PART_HorizontalScrollBar" Orientation="Horizontal" Grid.Row="1" telerik:StyleManager.Theme="{StaticResource Theme}" Visibility="Collapsed"/>
                </Grid>
                <telerik:RadBusyIndicator x:Name="PART_BusyIndicator" Grid.RowSpan="2" telerik:StyleManager.Theme="{StaticResource Theme}"/>
            </Grid>
        </ControlTemplate>
        <Style x:Key="RadPdfViewerStyle1" TargetType="telerik:RadPdfViewer">
            <Setter Property="Template" Value="{StaticResource FixedDocumentViewerBaseTemplate}"/>
        </Style>
    </Window.Resources>
     
        <Grid>
        <telerik:RadPdfViewer Style="{StaticResource RadPdfViewerStyle1}">
 
        </telerik:RadPdfViewer>
    </Grid>
</Window>



If you have any other questions feel free to reply, I will be subscribed to this thread.

Good luck!
Lancelot
0
Mohammad
Top achievements
Rank 1
answered on 24 May 2012, 03:25 PM
Hi Lancelot,

Thank you for your answer.
The problem hasn't been solved yet. When a pdf file is loaded, the grey background appears.
The grey color is because of the content control of the pdf viewer. Is there any way to change its background?

Thanks!
0
Lancelot
Top achievements
Rank 1
answered on 24 May 2012, 08:07 PM
Hi Mohammad,

I see what you are trying to do. You have two main options. The first and honestly the best way would be to use the built in themes the RadControls come with. Here is a link to see them in action on the RadPDFviewer (keep in mind you'll be looking at the Silverlight demo, but it is the same for WPF). Click on this link (http://demos.telerik.com/silverlight/#PdfViewer/Theming) to go to the PDFviewer Theming example.
 
On the left hand side you'll see the option to change the theme. Go ahead and try out all the different themes. If you like one of them, then all you need to do is set the theme. This link (http://www.telerik.com/help/wpf/common-styling-apperance-setting-theme-wpf.html) will bring you to the WPF documentation on how to set the theme, its just a couple lines of code.

You second option is to edit the content template. This link (http://www.telerik.com/help/wpf/common-styling-appearance-edit-control-templates-blend.html) will give you the basics on how to edit a control's style. Telerik does offer custom theme styling if your organization wants to create a completely custom control. Contact telerik Professional Services for more on that.
Good luck,
Lancelot
0
AvgurD
Top achievements
Rank 1
answered on 17 Jul 2012, 06:24 PM
Hi!
I want to change default template for PdfViewer in Metro theme - change white backround for gray or black. How I can do it? Without switch to other theme for this control (its not good - dll with theme have big size - just for one control its too expensive)?
I trying find this color in template of PdfViewer (in Blend) but all my changes of brushe had no effect. :(

Sorry for terrible English! 
0
Kammen
Telerik team
answered on 18 Jul 2012, 09:01 AM
Hello Dmitry,

All you need to do is to create your own style for the FixedDocumentPagesPresenter. Here is sample code that sets the Background blue.

<Style TargetType="ui:FixedDocumentPagesPresenter">
           <Setter Property="Background" Value="Blue" />
           <Setter Property="BorderThickness" Value="0" />
           <Setter Property="Padding" Value="0" />
           <Setter Property="Template">
               <Setter.Value>
                   <ControlTemplate TargetType="ui:FixedDocumentPagesPresenter">
                       <Grid>
                           <Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                               <ContentPresenter Margin="{TemplateBinding Padding}" />
                           </Border>
                       </Grid>
                   </ControlTemplate>
               </Setter.Value>
           </Setter>
       </Style>

Kind regards,
Kammen
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
PDFViewer
Asked by
Mohammad
Top achievements
Rank 1
Answers by
Lancelot
Top achievements
Rank 1
Mohammad
Top achievements
Rank 1
AvgurD
Top achievements
Rank 1
Kammen
Telerik team
Share this question
or