I have a UIElement
that I want to capture a snapshot of when a user clicks a button. When a user clicks the button, I want to take the UIElement
and load it's current state into an Image element. How do I render a UIElement
as an Image
?
相关问题
- Views base64 encoded blob in HTML with PHP
- How to get the background from multiple images by
- CV2 Image Error: error: (-215:Assertion failed) !s
- Replace image attributes for lazyload plugin on im
- how to Enumerate local fonts in silverlight 4
相关文章
- Use savefig in Python with string and iterative in
- Where does this quality loss on Images come from?
- Specifying image dimensions in HTML vs CSS for pag
- How to insert pictures into each individual bar in
- How do I append metadata to an image in Matlab?
- Img url to dataurl using JavaScript
- Click an image, get coordinates
- C# Saving huge images
You can also do the following:
Ultimately, no, you cannot render an entire
UIElement
, including the parts that aren't visible due to scrolling overflow, etc.I looked into how you could get around this using reflection. Unfortunately, you cannot override how
UIElement
renders, as it is just a light wrapper for the internal class XcpImports, which in turn is a wrapper for various native methods used throughout Silverlight. In other words,UIElement
and how it is rendered is completely native, and thus there is no (easy) way to override how it displays using reflection.If you wanted to take the hackish approach, you could enclose your element in a Grid, remove it from that grid, put it in another grid that is the same size as the element--see where I'm going with this? But that would be quite a hassle, and hackish at best.
Assuming the
FrameworkElement
you want to render is named elementToRender and theImage
where you want to place the rendered output is called image, use the following code on your button's click handler: