Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8687057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:01:21+00:00 2026-06-12T23:01:21+00:00

So I am trying to do a very simple thing in WP7 like: A

  • 0

So I am trying to do a very simple thing in WP7 like:

A button in MainPage will launch camera, and when camera successfully take a picture, I want to pass the picture to SecondPage and launch it.

Here’s my code:

Within the MainPage constructor, I initialize the camera task and set the delegate:

camTask.Completed += new EventHandler<PhotoResult>(camTask_Completed);

Then I implemented the camTask_Completed

 void camTask_Completed(object sender, PhotoResult e)
    {
        //throw new NotImplementedException();
        
        img = PictureDecoder.DecodeJpeg(e.ChosenPhoto);
        NavigationService.Navigate(new Uri("/SecondPage.xaml", UriKind.Relative));
    }

The application will run without error until after I pressed "accept" after I took the picture.

The exception says:

Exception {"Navigation is not allowed when the task is not in the foreground."} System.Exception {System.InvalidOperationException}

Which I understand is that I shouldn’t launch the SecondPage within the camTask_Completed method.

Then my question is: How to launch another page on the result of EventHandler?

Thanks

UPDATE: (For answer to this sub-question, please refer to this comment in this page)

I found another error right after I click the button(to launch the camera):

It throw an exception said:

"Type 'System.Windows.Media.Transform' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute."

Where could I serialize the Transform stuff?

I did some search on Google and found this:

Found the answer, the error actually suggests it too 🙂

[DataContract]

[KnownType(typeof(System.Windows.Media.MatrixTransform))]

Seemed it can resolve this problem, but where should I put these lines?

This is my code on MainPage to pass the image to SecondPage, img is a WriteableBitmap:

 protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
    {
        base.OnNavigatedFrom(e);
        var brush = new ImageBrush();
        brush.ImageSource = img;
        PhoneApplicationService.Current.State["bkg"] = brush;
    }

Thanks again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:01:22+00:00Added an answer on June 12, 2026 at 11:01 pm

    Perhaps You should try to use the dispatcher:

    activePage.Dispatcher.BeginInvoke(
         () => NavigationService.Navigate(new Uri("/SecondPage.xaml", UriKind.Relative)));
    

    This works in MetroApps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Very simple thing I'm trying to do here. I would like to have 2
I am trying to do a very simple thing. I want that when I
I'm trying to do a very simple thing, show alert with only 1 button,
I'm trying to do a very simple thing: Read a diff from a git
I am trying a very simple override. I just want to add one line
Very simple thing I am trying to do in JS (assign the values of
Trying to do very simple thing. Have too many of these fields: <input name=itempriceqty0
I am trying to achieve a very simple thing in MATLAB. I have a
I am trying to do a very simple thing, build an URL for a
I'm trying to do a very simple button that changes color based on mouseover,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.