Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6002455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:58:51+00:00 2026-05-23T00:58:51+00:00

A followup to this question: How do you hide a WPF DocumentViewer's menu bars?

  • 0

A followup to this question: How do you hide a WPF DocumentViewer's menu bars?

I’m totally new to WPF and not sure where to start with control template customization. MSDN doesn’t seem to help a lot.

All I need is to hide the main DocumentViewer toolbar, but when I try to customize the XAML file, it fails to compile. What are the customization steps?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:58:51+00:00Added an answer on May 23, 2026 at 12:58 am

    In WPF a control template is used to “skin” a control with a set of elements that compose the look-and-feel and the behavior of the control. You don’t have to know any more than that to start using control templates. The steps to customizing a control template are:

    1. Find the default style for ElementName (which includes the control template) using MSDN, ShowMeTheTemplate, Expression Blend or theme files
    2. Copy the default style into the resources of your application, usually in App.xaml or in an element’s resources such as a Window or Grid
    3. Change the key from x:Key="{x:Type ElementName}" to x:Key="myStyleName"
    4. Modify the control template to add, remove or change elements and properties from the defaults
    5. Use that style on instances of ElementName by adding the attribute Style="{StaticResource myStyleName}"

    So let’s do that. Here’s the default style for DocumentViewer from MSDN. We see a big section starting with <ToolBar ...> so we’ll delete all of that. Then if you follow the rest of the steps you’ll end up with XAML like this:

    <Grid>
        <Grid.Resources>
            <Style x:Key="documentViewerNoToolbarStyle"
                TargetType="{x:Type DocumentViewer}">
                <Setter Property="Foreground"
                    Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}" />
                <Setter Property="Background"
                    Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
                <Setter Property="FocusVisualStyle"
                    Value="{x:Null}" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type DocumentViewer}">
                            <Border BorderThickness="{TemplateBinding BorderThickness}"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                Focusable="False">
                                <Grid KeyboardNavigation.TabNavigation="Local">
                                    <Grid.Background>
                                        <SolidColorBrush Color="{DynamicResource ControlLightColor}" />
                                    </Grid.Background>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto" />
                                        <RowDefinition Height="*" />
                                        <RowDefinition Height="Auto" />
                                    </Grid.RowDefinitions>
    
                                    <ScrollViewer Grid.Row="1"
                                        CanContentScroll="true"
                                        HorizontalScrollBarVisibility="Auto"
                                        x:Name="PART_ContentHost"
                                        IsTabStop="true">
                                        <ScrollViewer.Background>
                                            <LinearGradientBrush EndPoint="0.5,1"
                                                StartPoint="0.5,0">
                                                <GradientStop Color="{DynamicResource ControlLightColor}"
                                                    Offset="0" />
                                                <GradientStop Color="{DynamicResource ControlMediumColor}"
                                                    Offset="1" />
                                            </LinearGradientBrush>
                                        </ScrollViewer.Background>
                                    </ScrollViewer>
    
                                    <ContentControl Grid.Row="2"
                                        x:Name="PART_FindToolBarHost"/>
                                </Grid>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
        <DocumentViewer Style="{StaticResource documentViewerNoToolbarStyle}"/>
    </Grid>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is in part a followup to this question . I'm not sure the
THis is a followup to my previous question Font-dependent control positioning. It's an attempt
Followup question from this one: Swing font names do not match? (Making a font
This is a followup to this question . I seem to be stuck on
As kind of a followup to this question I've gotten a solution working on
This is a followup question of How to encode characters from Oracle to Xml?
(Followup to this question ) After surviving the first wave of incoming shipments (9
This is a followup to this question The first two answers are both correct
A followup to this question, Building select projects only with Team Foundation Build :
This is a followup to this question How to create a subdirectory for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.