开发者

WPF Create Bitmap of Window that hasn't been shown

Is it possible to create a bitmap of a window that hasn't been shown without using screenshots?

What I want to do is start my application, and have a main window that displays other windows. I use visual brush to display them after they've been shown, and the image stay开发者_运维知识库s after the window is closed, but how do I show an image of the window prior to Window.Show()?


I would guess that the window isn't rendered until it is needed, so there would be no way to get the flattened bitmap of it. I wonder if you could somehow make it "show" without being shown? Can you use Window.Hide() to your advantage? Just throwing it out there.

Also makes me think--why would you want to get a bitmap of a Window? Windows are for presenting UI, not for displaying as an abstract representation of a UI choice. Maybe creating an abstract icon for each choice would be more usable?


No way to do this without creating the Window first, as it won't be in the visual tree until it is created. You may create it in an area outside your working area and generate the bitmap from there. You need it laid-out first also because of bindings, layout transforms, etc.


You should get everything you need here: http://www.west-wind.com/weblog/posts/150676.aspx and here: http://www.codeproject.com/KB/WPF/WPF-Image-to-WebPage.aspx

The key is the RenderTargetBitmap class

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜