summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs
new file mode 100644
index 00000000..725829f4
--- /dev/null
+++ b/Xamarin.Forms.Platform.Android/Renderers/BoxRenderer.cs
@@ -0,0 +1,43 @@
+using System.ComponentModel;
+using Android.Views;
+
+namespace Xamarin.Forms.Platform.Android
+{
+ public class BoxRenderer : VisualElementRenderer<BoxView>
+ {
+ public BoxRenderer()
+ {
+ AutoPackage = false;
+ }
+
+ public override bool OnTouchEvent(MotionEvent e)
+ {
+ base.OnTouchEvent(e);
+ return !Element.InputTransparent;
+ }
+
+ protected override void OnElementChanged(ElementChangedEventArgs<BoxView> e)
+ {
+ base.OnElementChanged(e);
+ UpdateBackgroundColor();
+ }
+
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+
+ if (e.PropertyName == BoxView.ColorProperty.PropertyName || e.PropertyName == VisualElement.BackgroundColorProperty.PropertyName)
+ UpdateBackgroundColor();
+ }
+
+ void UpdateBackgroundColor()
+ {
+ Color colorToSet = Element.Color;
+
+ if (colorToSet == Color.Default)
+ colorToSet = Element.BackgroundColor;
+
+ SetBackgroundColor(colorToSet.ToAndroid(Color.Transparent));
+ }
+ }
+} \ No newline at end of file