iOS custom control not rendered / refreshed in Visual Studio designer

Hi,

  1. Everything works well in runtime.
  2. At design-time I see custom property in property panel and I can change color in this way.
  3. Custom control doesn't render/refresh in designer at design-time

My control:

[Register("CircleView"), DesignTimeVisible(true)]
public class CircleView: UIView
{
private UIColor circleColor;

    [Export("CircleColor"), Browsable(true)]
    public UIColor CircleColor
    {
        get { return circleColor; }
        set
        {
            circleColor = value;
            SetNeedsDisplay();
        }
    }        

    public CircleView(IntPtr p): base(p)
    {
        Initialize();
    }

    public CircleView()
    {
        Initialize();
    }

    private void Initialize()
    {
        circleColor = UIColor.Red;
        ContentMode = UIViewContentMode.Redraw;

        SetNeedsDisplay();
    }

    public override void Draw(CGRect rect)
    {
        base.Draw(rect);

        DrawCircle(CircleColor);
    }

    private void DrawCircle(UIColor color)
    {
        using (var context = UIGraphics.GetCurrentContext())
        {
            var a = Math.Min(Bounds.Size.Width, Bounds.Size.Height);
            var leftX = Bounds.GetMidX() - a / 2;
            var topY = Bounds.GetMidY() - a / 2;
            var rectangle = new CGRect(leftX, topY, a, a);

            context.SetFillColor(CircleColor.CGColor);
            context.FillEllipseInRect(rectangle);
        }
    }
}

I'm using VS 2015 Update 3.

Answers

  • MarcinKruszynskiMarcinKruszynski USMember ✭✭

    Microsoft Visual Studio Community 2015
    Version 14.0.25422.01 Update 3
    Microsoft .NET Framework
    Version 4.6.01586

    Xamarin 4.1.2.18 (fcbe082)
    Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

    Xamarin.Android 6.1.2.21 (1cf254d)
    Visual Studio extension to enable development for Xamarin.Android.

    Xamarin.iOS 9.8.2.22 (f37444a)
    Visual Studio extension to enable development for Xamarin.iOS.

  • MarcinKruszynskiMarcinKruszynski USMember ✭✭

    What's more, on clean less complicated VS project designer does render and refresh this custom control very well...
    I need investigate what differences stop rendering it at design-time at my app project...

Sign In or Register to comment.