|
public class DateTimeViewModel : INotifyPropertyChanged
{
private ObservableCollection<object> _startdate;
public ObservableCollection<object> StartDate
{
get { return _startdate; }
set { _startdate = value; RaisePropertyChanged("StartDate"); }
}
public DateTimeViewModel()
{
ObservableCollection<object> todaycollection = new ObservableCollection<object>();
//Select today dates
todaycollection.Add(DateTime.Now.Date.Year.ToString());
todaycollection.Add(CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(DateTime.Now.Date.Month).Substring(0, 3));
if (DateTime.Now.Date.Day < 10)
todaycollection.Add("0" + DateTime.Now.Date.Day);
else
todaycollection.Add(DateTime.Now.Date.Day.ToString());
if (DateTime.Now.Hour < 10)
todaycollection.Add("0" + DateTime.Now.Hour.ToString());
else
todaycollection.Add(DateTime.Now.Hour.ToString());
if (DateTime.Now.Minute < 10)
todaycollection.Add("0" + DateTime.Now.Minute.ToString());
else
todaycollection.Add(DateTime.Now.Minute.ToString());
this.StartDate = todaycollection;
}
} |
|
<local:DateTimePicker
x:Name="date"
ColumnHeaderHeight="40"
HorizontalOptions="Center"
PickerHeight="400"
PickerMode="Dialog"
PickerWidth="300"
SelectedItem="{Binding StartDate}"
VerticalOptions="Center"> |