MainPage.xaml's Button1_Click event contains
NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
postPhotoToFacebook();
Page1.xaml contains webbrowser (all aunthentication, authorization acitivities, login page etc.).
When user clicks Button1, the开发者_如何学C control is navigated to Page1.xaml.
Before finishing entire acitivities on Page1.xaml, it returns back to MainPage.xaml & executespostPhotoToFacebook().
Plz help.
Without knowing what postPhotoToFacebook()
does it's hard to say for sure, but I'm guessing that it contains some functionality relating to whatever is in Page1.xaml
As a general rule you shouldn't perform operations in a method after you Navigate
.
If you need to perform an operation in the background (such as communicating with Facebook) then you should do this in a separate thread. Either by creating a specific BackgroundWorker or a thread that runs in the background. You could also start the process asynchronously with a callback which runs off the UI thread.
If your posting of the photo to Facebook is related to or dependent upon Page1.xaml
or it having loaded then you should do this in a method triggered by an event of that page. (NavigatedTo
or Loaded
are probably the most appropriate).
If you just want to begin the uploading process and then navigate to Page1
then you could do this before calling Navigate()
.
精彩评论