-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
PickerGallery.cs
92 lines (80 loc) · 2.76 KB
/
PickerGallery.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms.Controls.Issues;
using Xamarin.Forms.PlatformConfiguration.iOSSpecific;
namespace Xamarin.Forms.Controls
{
public class PickerGallery : ContentPage
{
#region UpdateMode
public static readonly BindableProperty UpdateModeProperty = BindableProperty.Create(
nameof(UpdateMode),
typeof(UpdateMode),
typeof(PickerGallery),
default(UpdateMode));
public UpdateMode UpdateMode
{
get => (UpdateMode)GetValue(UpdateModeProperty);
set => SetValue(UpdateModeProperty, value);
}
#endregion
public PickerGallery()
{
var picker = new Picker { Title = "Dismiss in one sec", Items = { "John", "Paul", "George", "Ringo" } };
picker.Focused += async (object sender, FocusEventArgs e) =>
{
await Task.Delay(1000);
picker.Unfocus();
};
Label testLabel = new Label { Text = "", AutomationId = "test", ClassId = "test" };
Picker p1 = new Picker
{
BindingContext = this,
Title = "Pick a number",
Items = { "0", "1", "2", "3", "4", "5", "6" }
};
p1.SetBinding(PlatformConfiguration.iOSSpecific.Picker.UpdateModeProperty, UpdateModeProperty.PropertyName);
p1.SelectedIndexChanged += (sender, e) =>
{
testLabel.Text = "Selected Index Changed";
};
p1.SetAutomationPropertiesName("Title picker");
DatePicker datePicker = new DatePicker { BindingContext = this };
datePicker.SetBinding(PlatformConfiguration.iOSSpecific.DatePicker.UpdateModeProperty, UpdateModeProperty.PropertyName);
TimePicker timePicker = new TimePicker { BindingContext = this };
timePicker.SetBinding(PlatformConfiguration.iOSSpecific.TimePicker.UpdateModeProperty, UpdateModeProperty.PropertyName);
Picker updateModePicker = new EnumPicker
{
BindingContext = this,
Title = "Update Mode",
EnumType = typeof(UpdateMode)
};
updateModePicker.SetBinding(Picker.SelectedItemProperty, UpdateModeProperty.PropertyName, mode: BindingMode.TwoWay);
Content = new ScrollView
{
Content = new StackLayout
{
Padding = new Thickness(20, 20),
Children = {
new DatePicker (),
new TimePicker (),
new DatePicker { Format = "D" },
new TimePicker { Format = "T" },
new Picker {Title = "Set your favorite Beatle", Items = {"John", "Paul", "George", "Ringo"}},
new Picker {Title = "Set your favorite Stone", Items = {"Mick", "Keith", "Charlie", "Ronnie"}, SelectedIndex = 1},
new Picker {Title = "Pick", Items = {"Jason Smith", "Rui Marinho", "Eric Maupin", "Chris King"}, HorizontalOptions = LayoutOptions.CenterAndExpand},
picker,
testLabel,
updateModePicker,
p1,
datePicker,
timePicker
}
}
};
}
}
}