public PopupDatePicker() { Orientation = ScrollOrientation.Horizontal; HorizontalOptions = LayoutOptions.Center; Padding = 0; BackgroundColor = StyleManager.DarkAccentColor; var now = DateTime.Now; monthTiles = new List <TopPanelItem>(); for (int i = 1; i <= 12; i++) { IEnumerable <DateTime> days = CalendarHelper.GetDaysInMonth(i, now.Year); var dayPicker = new DayPicker(CalendarHelper.CreateDayLayouts(days)); dayPicker.DateChanged += (sender, e) => { SelectedDay = dayPicker.SelectedItem; DateChanged(sender, e); }; var month = new DateTime(now.Year, i, 1, 0, 0, 0, DateTimeKind.Local); var tab = new TopPanelItem(month.ToString("MMMM", new CultureInfo("en-US")), dayPicker) { WidthRequest = 100 }; if (month.Month == now.Month) { tab.IsSelected = true; currentMonthTile = tab; } monthTiles.Add(tab); } monthPicker = new PopupTopPanel(monthTiles); monthPicker.DefaultView = currentMonthTile.ContentView; DefaultView = monthPicker.DefaultView; Content = monthPicker; ScrollEnded += (sender, args) => { var position = (int)Math.Round(ScrollX / 115); if (position >= 0 && position < monthTiles.Count) { SelectMonthTile(monthTiles[position]); } }; Scrolled += (sender, args) => { var position = (int)Math.Round(args.ScrollX / 115); if (position >= 0 && position < monthTiles.Count) { HighlightItem(position); } }; }
private void ShowMonthLayout() { dayPicker = new DayPicker(CalendarHelper.CreateDayLayouts(CalendarHelper.GetDaysInMonth(selectedMonth, selectedYear))); monthButton.ContentView = dayPicker; SelectItem(monthButton); dayPicker.DateChanged += (sender, e) => SelectDate(new DateTime(SelectedDate.Year, SelectedDate.Month, dayPicker.SelectedItem, 0, 0, 0, DateTimeKind.Local)); if (SelectedDate.Month == selectedMonth) { dayPicker.SelectDay(SelectedDate.Day); } }
public PopupDatePicker() { Orientation = ScrollOrientation.Horizontal; HorizontalOptions = LayoutOptions.Center; Padding = 0; BackgroundColor = StyleManager.DarkAccentColor; var now = DateTime.Now; monthTiles = new List<TopPanelItem>(); for (int i = 1; i <= 12; i++) { IEnumerable<DateTime> days = CalendarHelper.GetDaysInMonth(i, now.Year); var dayPicker = new DayPicker(CalendarHelper.CreateDayLayouts(days)); dayPicker.DateChanged += (sender, e) => { SelectedDay = dayPicker.SelectedItem; DateChanged (sender, e); }; var month = new DateTime (now.Year, i, 1, 0, 0, 0, DateTimeKind.Local); var tab = new TopPanelItem(month.ToString("MMMM", new CultureInfo("en-US")), dayPicker) { WidthRequest = 100 }; if (month.Month == now.Month) { tab.IsSelected = true; currentMonthTile = tab; } monthTiles.Add(tab); } monthPicker = new PopupTopPanel(monthTiles); monthPicker.DefaultView = currentMonthTile.ContentView; DefaultView = monthPicker.DefaultView; Content = monthPicker; ScrollEnded += ( sender, args ) => { var position = (int) Math.Round(ScrollX/115); if (position >= 0 && position < monthTiles.Count) SelectMonthTile(monthTiles[position]); }; Scrolled += ( sender, args ) => { var position = (int) Math.Round(args.ScrollX/115); if (position >= 0 && position < monthTiles.Count) HighlightItem(position); }; }
private void ShowMonthLayout() { dayPicker = new DayPicker (CalendarHelper.CreateDayLayouts (CalendarHelper.GetDaysInMonth (selectedMonth, selectedYear))); monthButton.ContentView = dayPicker; SelectItem(monthButton); dayPicker.DateChanged += (sender, e) => SelectDate (new DateTime (SelectedDate.Year, SelectedDate.Month, dayPicker.SelectedItem, 0, 0, 0, DateTimeKind.Local)); if (SelectedDate.Month == selectedMonth) { dayPicker.SelectDay (SelectedDate.Day); } }