Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

Control working in debug on device and in simulator but not in Ad Hoc build

$
0
0

I have a control a built using NControl for Xamarin forms. It works in debug on the device and the simulator, but when I do an ad hoc build and test it, the controls don't show up. Anyone have any ideas why that might happen?

Here is my control code:

using NControl.Abstractions;
using Xamarin.Forms;
using NGraphics;
using System.Diagnostics;
using System.Collections.Generic;

namespace MyApp.Controls
{
    public class HalfRibbon : NControlView
    {
        public static BindableProperty EndPercentageProperty = 
            BindableProperty.Create<HalfRibbon, double> (p => p.EndPercentage, 0.07, 
                BindingMode.OneWay, null, EndPercentageChanged);

        public double EndPercentage 
        {
            get { return (double)GetValue(EndPercentageProperty); }
            set { SetValue(EndPercentageProperty, value); }
        }

        private static void EndPercentageChanged(BindableObject bindable, double oldValue, double newValue)
        {
            (bindable as HalfRibbon).Invalidate();
        }

        public static new BindableProperty BackgroundColorProperty = 
            BindableProperty.Create<HalfRibbon, Xamarin.Forms.Color> (
                p => p.BackgroundColor, Xamarin.Forms.Color.Transparent, BindingMode.OneWay, null, BackgroundColorChanged);

        public new Xamarin.Forms.Color BackgroundColor
        {
            get { return (Xamarin.Forms.Color)GetValue(BackgroundColorProperty); }
            set { SetValue(BackgroundColorProperty, value); }
        }

        private static void BackgroundColorChanged(BindableObject bindable, Xamarin.Forms.Color oldValue, Xamarin.Forms.Color newValue)
        {
            (bindable as HalfRibbon).Invalidate();
        }

        public HalfRibbon ()
        {
        }

        public override void Draw(NGraphics.ICanvas canvas, NGraphics.Rect rect)
        {
            base.Draw(canvas, rect);

            var backgroundBrush = new SolidBrush(new NGraphics.Color(BackgroundColor.R,
                BackgroundColor.G, BackgroundColor.B, BackgroundColor.A));

            var width = (WidthRequest > 0)? WidthRequest : rect.Width;
            var ribbonWidth = Math.Ceiling(width * EndPercentage);
            var height = (HeightRequest > 0)? HeightRequest : rect.Height;

            canvas.DrawPath(new PathOp []{ 
                new MoveTo(0, 0),
                new LineTo(width, 0),
                new LineTo(width - ribbonWidth, height / 2),
                new LineTo(width, height),
                new LineTo(0, height),
                new LineTo(0, 0),
                new ClosePath()
            }, null, backgroundBrush);
        }
    }
}

Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>