Can I use Silverlight's WriteableBitmap to save non-visible parts of my UI to a bitmap?
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 scr开发者_开发技巧oll down, "take a snapshot", and then scroll up again?
This is a feasibility question, and thus I don't have code to share.
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.
精彩评论