This repository was archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathCheckBoxCoreGalleryPage.cs
63 lines (51 loc) · 1.86 KB
/
CheckBoxCoreGalleryPage.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System.Collections.Generic;
using Xamarin.Forms.CustomAttributes;
namespace Xamarin.Forms.Controls
{
internal class CheckBoxCoreGalleryPage : CoreGalleryPage<CheckBox>
{
protected override bool SupportsFocus
{
get { return false; }
}
protected override bool SupportsTapGestureRecognizer
{
get { return false; }
}
protected override void Build(StackLayout stackLayout)
{
base.Build(stackLayout);
var isCheckedContainer = new ValueViewContainer<CheckBox>(Test.CheckBox.IsChecked, new CheckBox() { IsChecked = true, HorizontalOptions = LayoutOptions.Start }, "IsChecked", value => value.ToString());
Add(isCheckedContainer);
var checkedColorContainer = new ValueViewContainer<CheckBox>(Test.CheckBox.CheckedColor, new CheckBox() { IsChecked = true, Color = Color.Orange, HorizontalOptions = LayoutOptions.Start }, "Color", value => value.ToString());
Add(checkedColorContainer);
var groupList = new VisualStateGroupList();
var group = new VisualStateGroup();
var checkedVisualState = new VisualState
{
Name = "IsChecked"
};
checkedVisualState.Setters.Add(new Setter
{
Property = CheckBox.ColorProperty,
Value = Color.Orange
});
group.States.Add(checkedVisualState);
var normalVisualState = new VisualState
{
Name = "Normal"
};
normalVisualState.Setters.Add(new Setter
{
Property = CheckBox.ColorProperty,
Value = Color.Red
});
group.States.Add(normalVisualState);
groupList.Add(group);
var checkBoxStateManaged = new CheckBox() { Color = Color.Red, HorizontalOptions = LayoutOptions.Start };
VisualStateManager.SetVisualStateGroups(checkBoxStateManaged, groupList);
var unCheckedColorContainer = new ValueViewContainer<CheckBox>(Test.CheckBox.UncheckedColor, checkBoxStateManaged, "Color", value => value.ToString());
Add(unCheckedColorContainer);
}
}
}