6

Say I have some grid that you need to scroll down to see all of its lines, and I'm interested in saving some lines that are not currently visible as a bitmap. Is it feasible, or do I have to actually scroll down, "take a snapshot", and then scroll up again?

This is a feasibility question, and thus I don't have code to share.

r0u1i
  • 3,526
  • 6
  • 28
  • 36

1 Answers1

4

Yes. You can render any UIElement (and its children) to a writeable bitmap.

When you do that you also specify a transform. That means you can display any part of the UIElement (if you do not want it all).

Whether it is "visible" on screen is completely irrelevant to bitmap rendering. It does not work like a screen grab.

The output cropping is solely down to the size of the target bitmap and the render transform provided.

As an example Silverlight Rotate & Scale a bitmap image to fit within rectangle without cropping uses UIElements that are never part of the visual tree to create a bitmap that is then rendered.

Community
  • 1
  • 1
iCollect.it Ltd
  • 92,391
  • 25
  • 181
  • 202
  • Thanks. A follow up question - does this also mean that I can save a UIElement not currently visible on screen? – r0u1i Aug 04 '11 at 10:21
  • Yes. You can render any UIElement, attached to the visual tree or not. Added link to another [really cool] answer :) – iCollect.it Ltd Aug 04 '11 at 10:54
  • @TrueBlueAussie where u have added link ? – Ragavan Oct 29 '13 at 09:58
  • @User121212: The one and only link in the answer is the one I meant: http://stackoverflow.com/questions/6801546/silverlight-rotate-scale-a-bitmap-image-to-fit-within-rectangle-without-croppi/6802332#6802332 – iCollect.it Ltd Oct 29 '13 at 14:30
  • @TrueBlueAussie My question if i have UIelement means without rendering how to save as image in Silverlight ? – Ragavan Nov 07 '13 at 11:41
  • @User121212: Please ask questions as a question on Stack Overflow. The example shown in the link renders the bitmap disconnected from the screen (which is what you want). – iCollect.it Ltd Nov 07 '13 at 16:03