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 7849685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:36:22+00:00 2026-06-02T18:36:22+00:00

I must print a displayed TreeView. Rendering the root TreeViewItem to bitmap, gives me

  • 0

I must print a displayed TreeView.

Rendering the root TreeViewItem to bitmap, gives me an image of the whole (even non visible nodes) tree. Then I split the bitmap in “pages” to be printed. The rendering code:

m_Bitmap = new RenderTargetBitmap((int)l_RootTreeViewItem.ActualHeightDesiredSize.Width,
                                  (int)l_RootTreeViewItem.ActualHeight, 96, 96,
                                  PixelFormats.Pbgra32);

m_Bitmap.Render(l_RootTreeViewItem);

Works well for small size trees. If the tree is large, RenderTargetBitmap results in “Out Of Memory” Exception.

So, the idea is to render only parts of the visual to avoid memory problems. A Render method where I can choose which part of visual to render will be perfect…

m_Bitmap.Render(l_RootTreeViewItem, xOffset, yOffset, width, height);

… but doesn’t exist. Is there some way to do that ?

  • 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-06-02T18:36:23+00:00Added an answer on June 2, 2026 at 6:36 pm

    What I’ll do :

    • Create a VisualBrush of your l_RootTreeViewItem
    • Create a Rectangle and assign the visual brush to the Fill property
    • Play with VisualBrush.Viewbox and VisualBrush.Viewport to render the part of the tree view I’m interested in
    • Use RenderTargetBitmap.Render on my rectangle when needed

    EDIT

    Solution 2

    • Put l_RootTreeViewItem in a canvas
    • Set the ClipToBounds property of the canvas to true
    • Play with Canvas.Width, Canvas.Height properties and Canvas.Left, Canvas.Top attached properties to display only a part of the TreeViewItem
    • Use PrintDialog.PrintVisual on the canvas as needed.

      <Canvas Width="300" Height="300" ClipToBounds="True">
          <TreeViewItem Canvas.Left="-200" Canvas.Top="-100">
              ...
          </TreeViewItem>
      </Canvas>
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I must admin this is kind of funny even though I think I understand
At some point I must have moved files from one location to another using
I must have pressed on the wrong button at some point, and now when
Must Support IE6 and must Validate vs XHTML Strict 1.0! This is tricky to
Must I call -deleteRowsAtIndexPaths:withRowAnimation: inside an -beginUpdates -endUpdates block?
This must be a stupid question, but nevertheless I find it curious: Say I
I must be going out of my mind, because my unit tests are failing
it must be jquery I have file text.html with 6 div in (a,b,c,d,e,f) In
It must be a somewhat common event to change the name of a property
I must say that so far, I've probably just been darn lucky in that

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.