Import namespaces
using System.Windows.Media.Imaging; using System.IO; using Microsoft.Xna.Framework.Media;
Code:
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://www.cnblogs.com/wzwyc/p/4180631.html
Windows phone captures the code of the current screen save image