Progress Bar - UWP - Win10 phone deployment

Trying to get a progress bar working on a UWP project.

Firstly, adding ActivityIndicator.Color="Red" will crash the app. How come this isn't working and how should I change the progress color?

In addition, Background color is not showing. I see no background at all in fact. Just a small blue bar so it doesn't look much like a progress bar at all.

Any ideas how to make this work?

Posts

  • JordanMcDonaldJordanMcDonald USMember

    I see that ActivityIndicator is not part of the ProgressBar. Is there a bug in the XAML intellisense which is showing things like this?

    If anybody has the working XAML for UWP ProgressBar that would be awesome!

    Thanks

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    @JordanMcDonald - from what I can see the Xamarin Forms progress bar has no ability to set the foreground color. However the UWP native control will. (https://msdn.microsoft.com/library/windows/apps/xaml/windows.ui.xaml.controls.progressbar.aspx)

    This should be similar to what you have in Xaml.

    <ProgressBar BackgroundColor="Red" Progress="0.2" />

    The foreground color will have to be done in a custom renderer.

  • JohnHardmanJohnHardman GBUniversity mod

    @JordanMcDonald - As per @AdamP 's message, the XF progress bar does not currently provide a ForegroundColor. However, the ProgressBar is otherwise functional on UWP. The following are snippets from a prototype (C# rather than XAML) that works on UWP. Again, as per Adam's message, you will currently need a custom renderer to set the foreground color (or to make the bar a bit thicker).

        private ProgressBar _progressBar;
    
    
            _progressBar = new ProgressBar
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.Silver
            };
    
    
        private bool TimerCallback()
        {
            if (_progressBar != null)
            {
                double previousProgress = _progressBar.Progress;
    
                _progressBar.Progress += 0.01;
    
                if (_progressBar.Progress >= 1.0)
                    _progressStatusLabel.Text = "Complete";
                else if ((previousProgress < 0.3) && (_progressBar.Progress >= 0.3))
                    _progressStatusLabel.Text = "Connected";
                else if ((previousProgress < 0.4) && (_progressBar.Progress >= 0.4))
                    _progressStatusLabel.Text = "Downloading changes";
                else if ((previousProgress < 0.6) && (_progressBar.Progress >= 0.6))
                    _progressStatusLabel.Text = "Checking for conflicts";
                else if ((previousProgress < 0.8) && (_progressBar.Progress >= 0.8))
                    _progressStatusLabel.Text = "Uploading";
    
                return isActiveWindow && _progressBar.Progress < 1.0;
            }
            return false;
        }
    
Sign In or Register to comment.