blob: bd93b560e47ca746387df2bfb8c6ffdb1e869793 (
plain)
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
|
using System;
using System.ComponentModel;
namespace Xamarin.Forms
{
public static class CompressedLayout
{
public static readonly BindableProperty IsHeadlessProperty =
BindableProperty.Create("IsHeadless", typeof(bool), typeof(CompressedLayout), default(bool),
propertyChanged: OnIsHeadlessPropertyChanged);
public static bool GetIsHeadless(BindableObject bindable)
=> (bool)bindable.GetValue(IsHeadlessProperty);
public static void SetIsHeadless(BindableObject bindable, bool value)
=> bindable.SetValue(IsHeadlessProperty, value);
static void OnIsHeadlessPropertyChanged(BindableObject bindable, object oldValue, object newValue)
{
var ve = bindable as IVisualElementController;
if (ve == null)
return;
if (ve.IsPlatformEnabled)
throw new InvalidOperationException("IsHeadless can not be modified when the view is rendered");
}
static readonly BindablePropertyKey HeadlessOffsetPropertyKey =
BindableProperty.CreateReadOnly("HeadlessOffset", typeof(Point), typeof(CompressedLayout), default(Point));
[EditorBrowsable(EditorBrowsableState.Never)]
public static readonly BindableProperty HeadlessOffsetProperty = HeadlessOffsetPropertyKey.BindableProperty;
[EditorBrowsable(EditorBrowsableState.Never)]
public static Point GetHeadlessOffset(BindableObject bindable)
=> (Point)bindable.GetValue(HeadlessOffsetProperty);
internal static void SetHeadlessOffset(BindableObject bindable, Point value)
=> bindable.SetValue(HeadlessOffsetPropertyKey, value);
}
}
|