protected override void OnElementChanged(ElementChangedEventArgs <ContentView> e) { base.OnElementChanged(e); if (e.NewElement != null && e.OldElement == null) { var pancake = (Element as PancakeView); // HACK: When there are no children we add a Grid element to trigger DrawChild. // This should be improved upon, but I haven't found out a nice way to be able to clip // the children and add the border on top without using DrawChild. if (pancake.Content == null) { pancake.Content = new Grid(); } Validate(pancake); this.SetBackground(_drawable = new PancakeDrawable(pancake, Context.ToPixels)); SetupShadow(pancake); } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { var pancake = Element as PancakeView; Validate(pancake); base.OnElementPropertyChanged(sender, e); if (e.PropertyName == PancakeView.BorderColorProperty.PropertyName || e.PropertyName == PancakeView.BorderThicknessProperty.PropertyName || e.PropertyName == PancakeView.BorderIsDashedProperty.PropertyName || e.PropertyName == PancakeView.BorderDrawingStyleProperty.PropertyName || e.PropertyName == PancakeView.BorderGradientAngleProperty.PropertyName || e.PropertyName == PancakeView.BorderGradientEndColorProperty.PropertyName || e.PropertyName == PancakeView.BorderGradientStartColorProperty.PropertyName || e.PropertyName == PancakeView.BorderGradientStopsProperty.PropertyName) { Invalidate(); } else if (e.PropertyName == PancakeView.SidesProperty.PropertyName || e.PropertyName == PancakeView.OffsetAngleProperty.PropertyName || e.PropertyName == PancakeView.HasShadowProperty.PropertyName || e.PropertyName == PancakeView.ElevationProperty.PropertyName) { SetupShadow(pancake); } else if (e.PropertyName == PancakeView.CornerRadiusProperty.PropertyName) { Invalidate(); SetupShadow(pancake); } else if (e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName) { _drawable.Dispose(); this.SetBackground(_drawable = new PancakeDrawable(pancake, Context.ToPixels)); } }