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 8129411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:18:05+00:00 2026-06-06T08:18:05+00:00

I am trying to use performance progressbar in a WP7 project but I have

  • 0

I am trying to use performance progressbar in a WP7 project but I have trouble with the async webclient call. My code is as follows:

Update

    public MainPage()
    {
        InitializeComponent();
         ...................

        this.Loaded += new RoutedEventHandler(MainPage_Loaded);}

    private void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        if (!App.ViewModel.IsDataLoaded)
        {
            App.ViewModel.LoadData();
        }
    }

And the ViewModel where I implement the LoadData function

    private bool _showProgressBar = false;
    public bool ShowProgressBar
    {
        get { return _showProgressBar; }
        set
        {
            if (_showProgressBar != value)
            {
                _showProgressBar = value;
                NotifyPropertyChanged("ShowProgressBar");
            }
        }
    public void LoadData()
    {
        try
        {
            string defaulturl = "http://....";
            WebClient client = new WebClient();
            Uri uri = new Uri(defaulturl);
            client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
            ShowProgressBar = true;
            client.DownloadStringAsync(uri);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

        this.IsDataLoaded = true;

    }

    void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        try
        {
            //fetch the data
           ShowProgressBar = false;
        }

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

    }

    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged(String propertyName)
    {.....
    } 

MainPage Xaml

    <toolkit:PerformanceProgressBar Margin="0,-12,0,0" x:Name="performanceProgressBar" IsIndeterminate="true" Visibility="{Binding ShowProgressBar, Converter={StaticResource BooleanToVisibilityConverter}}"/>

My problem is that because the WebClient is an async method when it is executed, the LoadData has already been executed and I can’t figure out where to place the performanceProgressBar.Visibility

Any help would be appreciated. Thanks!

  • 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-06T08:18:08+00:00Added an answer on June 6, 2026 at 8:18 am

    After you explained more in your comments, I understand more. Sounds like you want to bind a boolean property to the visibility of your progress bar. You’ll need a boolean-to-visbility converter (google it, it’s easy to find).

    Then you can do something like this:

    private bool _showProgressBar = false;
    public bool ShowProgressBar
    {
        get { _return _showProgressBar; }
        set 
        { 
            _return _showProgressBar;
            OnPropertyChanged("ShowProgressBar");
        }
    }
    
    public void LoadData()
    {
        try
        {
            string defaulturl = "http://....";
            WebClient client = new WebClient();
            Uri uri = new Uri(defaulturl);
            client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
    
            ShowProgressBar = true;
    
            client.DownloadStringAsync(uri);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    
        this.IsDataLoaded = true;
    
    }
    
    void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        try
        {
            //fetch the data
            ShowProgressBar = false;
        }
    
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    
    }
    

    On the View:

    <MyProgressBar Visibility={Binding Path=ShowProgressBar, Converter={StaticResource MyBoolToVisibleConverter}>
    

    Apparently, MSFT offers a converter for you already…this is news to me: http://msdn.microsoft.com/en-us/library/system.windows.controls.booleantovisibilityconverter.aspx

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

Sidebar

Related Questions

I'm trying to use a for_each loop in my code, but I'm getting the
I'm trying to use c#'s performance counters to track the throughput of an application
I'm trying to use SQL Server Profiler (2005) to track down some application performance
I was trying use svn to find a checkin using svn log, but it
Hi I'm trying use a datepicker on a field I have. I'm trying to
Trying to use code from here Im trying to incorporate both classes so that
I'm trying to use the Resource Governor in SQL Server 2008 but I find
I was trying to use XTEA encryption on NETMF using the code from blog
We're trying to use oprofile to track down performance problems on a server cluster.
I'm trying to use as little memory as possible in my code. I've tried

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.