save picture on picture control to local error: Unable to cast object of type ' System.Windows.Media.Imaging.BitmapFrameDecode to type ' System.Windows.Media.Imaging.BitmapImage ".
Try{System.Windows.Controls.MenuItem MenuItem= Sender asSystem.Windows.Controls.MenuItem; BitmapImage Bitmap=(BitmapImage) Imgphoto.source; (wrong place) Jpegbitmapencoder Encoder=NewJpegbitmapencoder (); Encoder. Frames.add (Bitmapframe.create (bitmap)); FileStream FileStream=NewFileStream (Savefilename, FileMode.Create, FileAccess.ReadWrite); Encoder. Save (FileStream); Filestream.close (); } Catch(Exception ex) {Console.WriteLine (ex). ToString ());
}
Modified to:
BitmapSource bitmap = (bitmapsource) Imgphoto.source;
can solve the problem
Save picture on picture control to local error: Unable to cast object of type ' System.Windows.Media.Imaging.BitmapFrameDecode to type ' System.Windows.Media.Imaging.BitmapImage ".