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 pathSwitchCoreGalleryPage.cs
51 lines (43 loc) · 1.93 KB
/
SwitchCoreGalleryPage.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
using Xamarin.Forms.CustomAttributes;
namespace Xamarin.Forms.Controls
{
internal class SwitchCoreGalleryPage : CoreGalleryPage<Switch>
{
protected override bool SupportsFocus
{
get { return false; }
}
protected override bool SupportsTapGestureRecognizer
{
get { return false; }
}
protected override void Build(StackLayout stackLayout)
{
base.Build(stackLayout);
var isToggledContainer = new ValueViewContainer<Switch>(Test.Switch.IsToggled, new Switch(), "IsToggled", value => value.ToString());
var onColoredSwitch = new Switch() { OnColor = Color.HotPink };
var onColorContainer = new ValueViewContainer<Switch>(Test.Switch.OnColor, onColoredSwitch, "OnColor", value => value.ToString());
var changeOnColorButton = new Button
{
Text = "Change OnColor"
};
var clearOnColorButton = new Button
{
Text = "Clear OnColor"
};
changeOnColorButton.Clicked += (s, a) => { onColoredSwitch.OnColor = Color.Red; };
clearOnColorButton.Clicked += (s, a) => { onColoredSwitch.OnColor = Color.Default; };
onColorContainer.ContainerLayout.Children.Add(changeOnColorButton);
onColorContainer.ContainerLayout.Children.Add(clearOnColorButton);
var thumbColorSwitch = new Switch() { ThumbColor = Color.Yellow };
var thumbColorContainer = new ValueViewContainer<Switch>(Test.Switch.ThumbColor, thumbColorSwitch, nameof(Switch.ThumbColor), value => value.ToString());
var changeThumbColorButton = new Button { Text = "Change ThumbColor", Command = new Command(() => thumbColorSwitch.ThumbColor = Color.Lime) };
var clearThumbColorButton = new Button { Text = "Clear ThumbColor", Command = new Command(() => thumbColorSwitch.ThumbColor = Color.Default) };
thumbColorContainer.ContainerLayout.Children.Add(changeThumbColorButton);
thumbColorContainer.ContainerLayout.Children.Add(clearThumbColorButton);
Add(isToggledContainer);
Add(onColorContainer);
Add(thumbColorContainer);
}
}
}