protected override void OnSizeAllocated(double width, double height) { base.OnSizeAllocated(width, height); if (width <= 0 || height <= 0) { return; } var bounds = new Rectangle(0, 0, width, height); var w = Math.Min(width, height); var center = bounds.Center; var half = w / 2; var bRect = new Rectangle(center.X - half, center.Y - half, w, w); BackgroundView.BorderRadius = half; BackgroundView.Layout(bRect); thumbRadius = w / 4; Thumb.HeightRequest = Thumb.WidthRequest = half; Thumb.BorderRadius = thumbRadius; ThumbCenter = Center; Radius = half; UpdateThumb(); }
protected override void LayoutChildren(double x, double y, double width, double height) { var bounds = new Rectangle(x, y, width, height); if (lastBounds == bounds) { return; } lastBounds = bounds; var w = Math.Min(width, height); var center = bounds.Center; var half = w / 2; var bRect = new Rectangle(center.X - half, center.Y - half, Radius * 2, Radius * 2); BackgroundView.Layout(bRect); thumbRadius = width / 4; Thumb.Layout(new Rectangle(0, 0, Radius, Radius)); UpdateThumb(); }