Xamarin circular activity indicator for UWP

1.5k views Asked by At

Is there a custom circular activity indicator for UWP/ Win10 apps using Xamarin?

1

There are 1 answers

0
Elvis Xia - MSFT On BEST ANSWER

Is there a custom circular activity indicator for UWP/ Win10 apps using Xamarin?

You need to create your own View for UWP's ProgressRing:

Shared Project\MyProgressRing.cs:

public class MyProgressRing:View
{
}

UWP Project\MyProgressRingRenderer.cs:

[assembly:ExportRenderer(typeof(MyProgressRing),typeof(MyProgressRingRenderer))]
namespace CircularActivityDemo.UWP
{
    public class MyProgressRingRenderer:ViewRenderer<MyProgressRing,ProgressRing>
    {
        ProgressRing ring;
        protected override void OnElementChanged(ElementChangedEventArgs<MyProgressRing> e)
        {
            base.OnElementChanged(e);
            if (Control == null)
            {
                ring = new ProgressRing();
                ring.IsActive = true;
                ring.Visibility = Windows.UI.Xaml.Visibility.Visible;
                ring.IsEnabled = true;
                SetNativeControl(ring);
            }
        }
    }
}

Notes: I hardcoded the properties of ProgressRing Control. You can create DependencyProperties for your custom ProgressRing control.