I need to save image corresponding to a UIElement
.
I have tried following Generate BitmapSource from UIElement link for WPF but this is not working in Metro apps due to limited API.
DirectX is a way, but there is a steep learning curve.
I need to save image corresponding to a UIElement
.
I have tried following Generate BitmapSource from UIElement link for WPF but this is not working in Metro apps due to limited API.
DirectX is a way, but there is a steep learning curve.
This is now available in Windows 8.1 see http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.media.imaging.rendertargetbitmap.aspx
There is no way other than rendering it yourself, which you can do either using WriteableBitmap
or DirectX depending on what you want to achieve. It's all due to the missing WriteableBitmap.Render()
method that was available in Silverlight and similar method from WPF.
*EDIT 1
Similar question also keeps being asked on Stack Overflow and MSDN. Hopefully an easy method to do it in WinRT/XAML is made available in the near future, but for now you have to use these workarounds.
*EDIT 2
I have just worked on it for a very short time, but I am working on implementing some basic composition code to render a visual tree to a bitmap. Got it working for some basic TextBlocks for now, but I might add other pieces soon too. You can use the code to add the elements you need in your scenario.