Import the following namespaces:
using System.Windows.Media.Imaging; using System.IO; using Microsoft.Xna.Framework.Media;
The full code is as follows:
Public voidCapturescreen (Objectsender, EventArgs e) {WriteableBitmap BMP=NewWriteableBitmap (480, -); Bmp. Render (App.Current.RootVisual,NULL); Bmp. Invalidate (); MemoryStream Stream=NewMemoryStream (); Bmp. Savejpeg (Stream, BMP. Pixelwidth, BMP. Pixelheight,0, the); Stream. Seek (0, Seekorigin.begin); Medialibrary Library=Newmedialibrary (); stringFileName ="Screenshot_"+ DateTime.Now.ToString ("Yyyy-mm-dd_hh:mm:ss"); Library. SavePicture (FileName, stream); Stream. Close (); Dispatcher.begininvoke (()={picturecollection piccollection=Library. Pictures; foreach(Picture iteminchpiccollection) { if(Item! =NULL) {BitmapImage bitmap=NewBitmapImage (); Bitmap. SetSource (item. GetImage ()); } } });}
Transferred from: http://terryblog.blog.51cto.com/1764499/551752/
Windows phone captures the code of the current screen save image