protected override void OnElementChanged(ElementChangedEventArgs <Frame> e) { base.OnElementChanged(e); if (e.NewElement != null) { double borderWidth = FrameProps.GetBorderWidth(e.NewElement); if (borderWidth != (double)FrameProps.BorderWidthProperty.DefaultValue) { Control.BorderThickness = new Windows.UI.Xaml.Thickness(borderWidth); } } }
protected override void OnElementChanged(ElementChangedEventArgs <Frame> e) { base.OnElementChanged(e); if (e.NewElement != null) { double borderWidth = FrameProps.GetBorderWidth(e.NewElement); Color borderColor = e.NewElement.BorderColor; if (borderWidth != (double)FrameProps.BorderWidthProperty.DefaultValue && borderColor.IsDefault == false) { GradientDrawable _backgroundDrawable = (GradientDrawable)typeof(Xamarin.Forms.Platform.Android.FastRenderers.FrameRenderer) .GetField(nameof(_backgroundDrawable), BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this); DisplayMetrics displayMetrics = Context.Resources.DisplayMetrics; int borderWidthInPixel = (int)Math.Round(borderWidth * (displayMetrics.Xdpi / (int)DisplayMetricsDensity.Default)); _backgroundDrawable.SetStroke(borderWidthInPixel, borderColor.ToAndroid()); } } }