Note that there are some explanatory texts on larger screens.

plurals
  1. POWP7 - wait to start Main Page untill asynchronous call is done
    text
    copied!<p>The app I'm making needs to get some data from a json REST service before navigating to the first page (MainView.xaml). The controller class that makes requests for the viewmodels has a few static Lists that help mapping IDs (that could have changed since last run) it uses to generate REST requests for viewmodels later. When the MainView is initialized it immediately calls for information from this controller class, which would fail because the ID mappings haven't loaded yet. Therefore I load a view called LoadingScreen instead. This view runs the controller's method which maps the IDs and afterwards navigates the application's view to MainView.</p> <pre><code>public LoadingScreen() { Dispatcher.BeginInvoke(TVController.populateMaps); InitializeComponent(); } </code></pre> <p>After mapping the IDs, the controller does this</p> <pre><code>Deployment.Current.Dispatcher.BeginInvoke(() =&gt; { (Application.Current.RootVisual as PhoneApplicationFrame).Navigate(new Uri("/View/MainView.xaml", UriKind.Relative)); }); </code></pre> <p>But I'd like to avoid having a temporary view for two reasons:</p> <ol> <li>The back button leads users to this page later on</li> <li>It's bad coding. I'd like to only have to tamper with the SplashScreen image.</li> </ol> <p>I have been looking at alternative ways of doing this, and I've managed to prevent the default task navigation by WMAppManifest.xml to the LoadingScreen (in App.xaml.cs). But my breakpoints in the controller class seems to suggest nothing is done in its PopulateMaps method and asynchronous request when I run it from App.xaml.cs. This is amongst other things what I've tried:</p> <pre><code>public App() { //INITIALIZING THE ELEMENTARY STUFF ....... RootFrame.Navigating += new NavigatingCancelEventHandler(RootFrame_Navigating); } void RootFrame_Navigating(object sender, NavigatingCancelEventArgs e) { e.Cancel = true; TVController.populateMaps(); } </code></pre> <p>What I want to find is a way to avoid having a temporary loading screen.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload