-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCustomTimePicker.cs
More file actions
88 lines (69 loc) · 2.52 KB
/
CustomTimePicker.cs
File metadata and controls
88 lines (69 loc) · 2.52 KB
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
using Syncfusion.Maui.Picker;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
namespace TimePickerSample.Control
{
public class CustomTimePicker : SfPicker
{
//Minute is the collection of minute numbers
public PickerColumn Minute;
//Hour is the collection of hour numbers
public PickerColumn Hour;
//Format is the collection of AM and PM
public PickerColumn Format;
private ObservableCollection<string> hours, minutes, formats;
public CustomTimePicker()
{
Hour = new PickerColumn();
Minute = new PickerColumn();
Format = new PickerColumn();
hours = new ObservableCollection<string>();
minutes = new ObservableCollection<string>();
formats = new ObservableCollection<string>();
PopulateTimeCollection();
this.Columns.Add(Hour);
this.Columns.Add(Minute);
this.Columns.Add(Format);
this.ColumnHeaderView.Height = 40;
this.FooterView.Height = 40;
this.FooterView.ShowOkButton = true;
this.HeaderView.Height = 40;
this.HeaderView.Text = "Select Time";
this.ColumnHeaderView.TextStyle.TextColor = Color.FromArgb("#6750A4");
this.ColumnHeaderView.DividerColor = Color.FromArgb("#6750A4");
this.FooterView.DividerColor = Color.FromArgb("#6750A4");
this.HeaderView.TextStyle.TextColor = Color.FromArgb("#6750A4");
this.TextStyle.TextColor = Color.FromArgb("#6750A4");
this.ColumnDividerColor = Colors.Transparent;
this.HeaderView.DividerColor = Color.FromArgb("#6750A4");
}
private void PopulateTimeCollection()
{
//Populate Hour
for (int i = 1; i <= 12; i++)
{
hours.Add(i.ToString());
}
//Populate Minute
for (int j = 0; j < 60; j++)
{
if (j < 10)
{
minutes.Add("0" + j);
}
else
minutes.Add(j.ToString());
}
//Populate Format
formats.Add("AM");
formats.Add("PM");
Hour.ItemsSource = hours;
Minute.ItemsSource = minutes;
Format.ItemsSource = formats;
Hour.HeaderText = "Hour";
Minute.HeaderText = "Minute";
}
}
}