Hi
Could someone offer me a bit of help?
I started using Xamarin today.
I've extended a ListView to have extra spacing etc, and appear how I wanted it.
That worked fine when I threw together a custom renderer.
Same for my CircularBox, which draws a number in the centre of it.
What I am trying to do now is take the RadialProgress control from the Component store, and get it to show up in a Forms project.
I thought all I would have to do would be create the class for it in the PCL (like so):
public class RadialProgressValue : View
{
public static readonly BindableProperty MinimumProperty = BindableProperty.Create<RadialProgressValue, int>(p => p.Minimum, default(int));
public int Minimum
{
get { return (int)GetValue(MinimumProperty); }
set { SetValue(MinimumProperty, value); }
}
public static readonly BindableProperty MaximumProperty = BindableProperty.Create<RadialProgressValue, int>(p => p.Maximum, default(int));
public int Maximum
{
get { return (int)GetValue(MaximumProperty); }
set { SetValue(MaximumProperty, value); }
}
public static readonly BindableProperty FillColorProperty = BindableProperty.Create<RadialProgressValue, Color>(p => p.FillColor, default(Color));
public Color FillColor
{
get { return (Color)GetValue(FillColorProperty); }
set { SetValue(FillColorProperty, value); }
}
}
Then create a custom renderer for it in the Actual Android project like so:
[assembly: ExportRenderer(typeof(RadialProgressValue), typeof(RadialProgressRenderer))]
namespace Sandbox.Droid
{
public class RadialProgressRenderer : ViewRenderer<RadialProgressValue, RadialProgressView>
{
RadialProgressView _radial;
public RadialProgressRenderer()
{
_radial = new RadialProgressView(Forms.Context);
}
protected override void OnElementChanged(ElementChangedEventArgs<RadialProgressValue> e)
{
base.OnElementChanged(e);
if (e.OldElement != null || this.Element == null)
return;
if (e.OldElement != null)
e.OldElement.PropertyChanged -= HandlePropertyChanged;
if (this.Element != null)
{
this.Element.PropertyChanged += HandlePropertyChanged;
}
var element = (RadialProgressValue)Element;
_radial.MaxValue = element.Maximum;
_radial.MinValue = element.Minimum;
SetNativeControl(_radial);
}
private void HandlePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == RadialProgressValue.MaximumProperty.PropertyName)
{
_radial.MaxValue = Element.Maximum;
}
else if (e.PropertyName == RadialProgressValue.MinimumProperty.PropertyName)
{
_radial.MinValue = Element.Minimum;
}
}
}
However, all I get is a blank StackLayout in the Page.
Can't figure out why.
The component in question is: https://components.xamarin.com/view/radialprogress
Thanks!