0

I am wondering why when I load my windows phone project, the application bar is appearing on my first screen which is just a loading background.

How can I make it appear at the really end of the loading?

This is the code I use:

public MainPage()
    {
        InitializeComponent();

        AnimationContext = LayoutRoot;  //  for page transitions
        _tappedListBox = null;   //  used for setting the activated ListBox on panorama for animation to map page

        // If the constructor has been called, this is not a page that was already in memory:
        _newPageInstance = true;

        //  Setup the background thread worker properties:
        _worker = new BackgroundWorker();   //  Create a background thread worker for downloading/installing park maps
        _worker.WorkerReportsProgress = true;
        _worker.WorkerSupportsCancellation = true;
        _worker.DoWork += new DoWorkEventHandler(worker_DoWork);
        _worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
        _worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);

        // Set the data context of the listbox control to the sample data
        this.DataContext = App.ViewModel;
        this.Loaded += new RoutedEventHandler(MainPage_Loaded);


    }

And I set the visibility here:

    private void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        if (!App.ViewModel.IsDataLoaded)
            App.ViewModel.LoadData();
        ;   //  load panorama data (if need to)

        if (!App.ViewModel.IsDataLoaded == false)
        {
            this.ApplicationBar.IsVisible = true;
        }
    }
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Kiwimoisi
  • 4,086
  • 6
  • 33
  • 64
  • 3
    if (!App.ViewModel.IsDataLoaded == false) Did you really mean to write your if statement this way? I would lose either the ! or the == false from there, it's very confusing to read! – mgnoonan Mar 13 '12 at 14:47
  • Agree, although you actually need to lose both to maintain the same result. Should just be "if (App.ViewModel.IsDataLoaded)". – Nomad101 Mar 13 '12 at 15:09

1 Answers1

4

Pu it this.ApplicationBar.IsVisible = true; inside _worker.RunWorkerCompleted event handler instead of Loaded event

Ku6opr
  • 8,126
  • 2
  • 24
  • 31