Ooui-tws-port/Ooui.Forms/Renderers/BoxRenderer.cs

38 lines
1.1 KiB
C#
Raw Normal View History

using System;
using System.ComponentModel;
using Ooui.Forms.Extensions;
using Xamarin.Forms;
namespace Ooui.Forms.Renderers
{
public class BoxRenderer : VisualElementRenderer<BoxView>
{
Ooui.Color _colorToRenderer;
protected override void OnElementChanged (ElementChangedEventArgs<BoxView> e)
{
base.OnElementChanged (e);
if (Element != null)
SetBackgroundColor (Element.BackgroundColor);
}
protected override void OnElementPropertyChanged (object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged (sender, e);
if (e.PropertyName == BoxView.ColorProperty.PropertyName)
SetBackgroundColor (Element.BackgroundColor);
}
protected override void SetBackgroundColor (Xamarin.Forms.Color color)
{
if (Element == null)
return;
2018-04-26 05:23:26 +00:00
_colorToRenderer = Element.Color.ToOouiColor (Colors.Clear);
Style.BackgroundColor = _colorToRenderer;
}
}
}