All, I have a basic Windows 7 Phone application and I have just finished a crop page, where the users are able to crop an image taken with the phones camera. In the cameraCapTask_Completed
event I set the App's global WritableBitmap
public static WriteableBitmap capturedImage;
as follows
void cameraCapTask_Completed(object sender, PhotoResult e)
{
if (e.TaskResult == TaskResult.OK && e.ChosenPhoto != null)
{
// Take JPEG stream and decode into a WriteableBitmap object.
App.capturedImage = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
When I take a picture I then pass it to the cropping page in the CropProcessPage
constructor I set the Image in the page via
public CropProcessPage()
{
InitializeComponent();
// Set the text and display captured image.
imageMain.Source = App.capturedImage;
This works. However, when I go back to the Main Page and retake/take another image, when I try to the new image, the old image (the first one taken) is shown. The constructor is being called and so is the camera captured event (setting the new image). What am I doing wrong here?
In CropProcessPage
move line
imageMain.Source = App.capturedImage;
to
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
// Set the text and display captured image.
imageMain.Source = App.capturedImage;
}