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

  • Home
  • SEARCH
  • 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 6469821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:02:17+00:00 2026-05-25T06:02:17+00:00

This question has a solution: How do you hide a WPF DocumentViewer's menu bars?

  • 0

This question has a solution:
How do you hide a WPF DocumentViewer's menu bars?

However, it only allows hiding the toolbar through XAML. I need to get this done programmatically.

This answer: WPF: How can I remove the searchbox in a DocumentViewer? hides the search bar programmatically.

How do I hide the main toolbar via non-xaml code?

  • 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-25T06:02:18+00:00Added an answer on May 25, 2026 at 6:02 am

    There is nothing in a DocumentViewer which ensures that the toolbar is even there, that being the case a programmatic manipulation of the control at run-time to remove a toolbar which may or may not exist might not be such a good idea. Of course you can do some null-checking and exception handling but that is not very clean either.

    For the default aero template the following code will knock out the toolbar:

    var contentHost = viewer.Template.FindName("PART_ContentHost", viewer) as ScrollViewer;
    var grid = contentHost.Parent as Grid;
    grid.Children.RemoveAt(0);
    

    I remove the toolbar indirectly as it is not a PART, this is the reason why it may not even exist in some themes.

    Ideally you should override the template completely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit This question has gone through a few iterations by now, so feel free
I realise this question has been asked 100 times, but i've looked through the
I know this question has been posted here before, and I've trawled through as
This question has been asked many times, but I tried every solution and none
This question has answer in other languages/platforms but I couldn't find a robust solution
I feel like this question has been asked many times, but the solution is
This question has been asked before, see: jQuery select only tr/td in main table,
This question has been retitled/retagged so that others may more easily find the solution
I know the question already has a solution (eg. this question ) but I
This question has been asked before ( link ) but I have slightly different

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.