New: XDA launches forum for app developers. Discuss coding, tools, marketing, and more.
XDA Developers Android and Mobile Development Forum
Forgot your password?
 
Post Reply+
Tip us?
 
GFR_2009
Old
#1  
Member - OP
Thanks Meter 0
Posts: 37
Join Date: Oct 2009
Default [Q] WP7 - ProgressBar sample?

Hi there,

I'm a little bit stuck with a page transition.

In my app, I select a name from a listbox which is located in another page (Page 2)

Once the name is selected from the listbox (in page 2) it automatically returns to the calling page.

Problem is that during the transition, in the OnNavigatedTo event of Page 1, it fires a query which takes some time and the transition is freezed during that time.

How can I add a ProgressBar to warn the user?

If possible, I'd like to stay as "official" as possible, so my idea is to use the standard ProgressBar supllied in the RTW.

I tried many searches and found nothing close to a workable sample on this.

Any help is much apprecitated in advance!
 
williammel
Old
(Last edited by williammel; 14th February 2011 at 06:47 AM.)
#2  
Member
Thanks Meter 3
Posts: 66
Join Date: Nov 2010
Quote:
Originally Posted by GFR_2009 View Post
Hi there,

I'm a little bit stuck with a page transition.

In my app, I select a name from a listbox which is located in another page (Page 2)

Once the name is selected from the listbox (in page 2) it automatically returns to the calling page.

Problem is that during the transition, in the OnNavigatedTo event of Page 1, it fires a query which takes some time and the transition is freezed during that time.

How can I add a ProgressBar to warn the user?

If possible, I'd like to stay as "official" as possible, so my idea is to use the standard ProgressBar supllied in the RTW.

I tried many searches and found nothing close to a workable sample on this.

Any help is much apprecitated in advance!

If you're not already using the PerformanceProgressBar, you should be.

http://www.jeff.wilcox.name/2010/08/...ceprogressbar/

It's pretty much 'plug&play'.

There are 2 ideas which you could try to fix your problem.
An idea that you could try is using a DispatcherTimer. A timer will allow the function to finish loading, while creating an event which will fire to display the progress bar. When the page has finished loading, (say 1 sec) your timer could tick, and do whatever work you need done. Another solution would be to add a Loaded event on the page. This would allow you to run some code once the page is fully loaded. This is probably the best design. To do that, you'd need some code like this:

Code:
public MainPage()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(MainPage_Loaded);
        }

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            ProgressBar pb = new ProgressBar();
            pb.Style = PhoneApplicationService.Current.State["PerformanceProgressBar"] as Style;
            pb.IsIndeterminate = true;

//add it onto the page, since it wasn't done in XAML.
            LayoutRoot.Children.Add(pb);
        }
Note that you can still create the ProgressBar in XAML, it was just easier to only show 1 file.
The Following User Says Thank You to williammel For This Useful Post: [ Click to Expand ]
 
GFR_2009
Old
#3  
Member - OP
Thanks Meter 0
Posts: 37
Join Date: Oct 2009
williammel,

Thanks a lot for the answer. Very clear and helpful!

Will try it right now.

Cheers,

Gus