/
BoxView.cs
43 lines (35 loc) · 1.41 KB
/
BoxView.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.ComponentModel;
using Xamarin.Forms.Platform;
namespace Xamarin.Forms
{
[RenderWith(typeof(_BoxViewRenderer))]
public class BoxView : View, IColorElement, ICornerElement, IElementConfiguration<BoxView>
{
public static readonly BindableProperty ColorProperty = ColorElement.ColorProperty;
public static readonly BindableProperty CornerRadiusProperty = CornerElement.CornerRadiusProperty;
readonly Lazy<PlatformConfigurationRegistry<BoxView>> _platformConfigurationRegistry;
public BoxView()
{
_platformConfigurationRegistry = new Lazy<PlatformConfigurationRegistry<BoxView>>(() => new PlatformConfigurationRegistry<BoxView>(this));
}
public Color Color {
get => (Color)GetValue(ColorElement.ColorProperty);
set => SetValue(ColorElement.ColorProperty, value);
}
public CornerRadius CornerRadius {
get => (CornerRadius)GetValue(CornerElement.CornerRadiusProperty);
set => SetValue(CornerElement.CornerRadiusProperty, value);
}
public IPlatformElementConfiguration<T, BoxView> On<T>() where T : IConfigPlatform
{
return _platformConfigurationRegistry.Value.On<T>();
}
[Obsolete("OnSizeRequest is obsolete as of version 2.2.0. Please use OnMeasure instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected override SizeRequest OnSizeRequest(double widthConstraint, double heightConstraint)
{
return new SizeRequest(new Size(40, 40));
}
}
}