/// <summary> /// /// </summary> public AtomCalendar() { RowSpacing = 5; ColumnSpacing = 5; Padding = new Thickness(5); this.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto }); this.RowDefinitions.Add(new RowDefinition { }); this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(2, GridUnitType.Star) }); this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(8, GridUnitType.Star) }); this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(5, GridUnitType.Star) }); this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(2, GridUnitType.Star) }); listView = new AtomGridView(); /*listView.SetBinding(AtomListView.TapCommandProperty, new Binding() { * Source = this, * Path = nameof(TapCommand) * });*/ listView.TapCommand = new AtomCommand(o => { try { isDateChanging = true; this.SelectedDate = ((AtomDateModel)o).Value; } finally { isDateChanging = false; } TapCommand?.Execute(o); return(Task.CompletedTask); }); monthPicker = new AtomChooser() { ValuePath = "Value" }; DateTime start = new DateTime(2012, 1, 1); for (int i = 0; i < 12; i++) { monthList.Add(new AtomData <int>(start.ToString("MMMMMM"), i + 1)); start = start.AddMonths(1); } //monthPicker.SelectedIndexChanged += (s, e) => { // CurrentMonth = monthPicker.SelectedIndex + 1; //}; //monthPicker.SelectedIndex = CurrentMonth - 1; yearPicker = new AtomChooser() { ValuePath = "Value" }; yearPicker.LabelPath = monthPicker.LabelPath = "Label"; yearPicker.ItemTemplate = monthPicker.ItemTemplate = new DataTemplate(() => { Label label = new Label(); label.SetBinding(Label.TextProperty, new Binding() { Path = "Label" }); return(label); }); //yearPicker.SelectedIndexChanged += (s, e) => { // CurrentYear = int.Parse(yearPicker.Items[yearPicker.SelectedIndex]); //}; UpdateYears(); monthPicker.SetBinding(AtomChooser.ValueProperty, new Binding() { Source = this, Path = "CurrentMonth", Mode = BindingMode.TwoWay }); monthPicker.ShowSearch = false; monthPicker.ShowAsPopupButton = true; yearPicker.ShowSearch = false; yearPicker.ShowAsPopupButton = true; yearPicker.SetBinding(AtomChooser.ValueProperty, new Binding() { Source = this, Path = "CurrentYear", Mode = BindingMode.TwoWay }); yearPicker.ItemsSource = yearList; monthPicker.ItemsSource = monthList; // first row.. SetColumn(monthPicker, 1); SetColumn(yearPicker, 2); SetColumn(rightButton, 3); // second row SetColumnSpan(listView, 4); SetRow(listView, 1); this.Children.Add(leftButton); this.Children.Add(monthPicker); this.Children.Add(yearPicker); this.Children.Add(listView); this.Children.Add(rightButton); UpdateList(); leftButton.Command = new AtomCommand(() => { if (CurrentMonth == 1) { CurrentMonth = 12; CurrentYear = CurrentYear - 1; } else { CurrentMonth = CurrentMonth - 1; } return(Task.CompletedTask); }); rightButton.Command = new AtomCommand(() => { if (CurrentMonth == 12) { CurrentMonth = 1; CurrentYear = CurrentYear + 1; } else { CurrentMonth = CurrentMonth + 1; } return(Task.CompletedTask); }); }
public GridCell(int slices, DataTemplate dt, AtomGridView gridView) { this.Slices = slices; this.GridView = gridView; this.DataTemplate = dt; }