コード例 #1
0
        /// <summary>
        /// Inherited code: Requires comment.
        /// </summary>
        private void PopulateGrids()
        {
            if (MonthView != null)
            {
                for (int i = 0; i < GlobalCalendar.RowsPerMonth; i++)
                {
                    if (_dayTitleTemplate != null)
                    {
                        FrameworkElement cell = (FrameworkElement)_dayTitleTemplate.LoadContent();
                        cell.SetValue(Grid.RowProperty, 0);
                        cell.SetValue(Grid.ColumnProperty, i);
                        MonthView.Children.Add(cell);
                    }
                }

                for (int i = 1; i < GlobalCalendar.RowsPerMonth; i++)
                {
                    for (int j = 0; j < GlobalCalendar.ColumnsPerMonth; j++)
                    {
                        GlobalCalendarDayButton cell = new GlobalCalendarDayButton();

                        if (Owner != null)
                        {
                            cell.Owner = Owner;
                            Owner.ApplyDayButtonStyle(cell);
                        }
                        cell.SetValue(Grid.RowProperty, i);
                        cell.SetValue(Grid.ColumnProperty, j);
                        cell.CalendarDayButtonMouseDown += Cell_MouseLeftButtonDown;
                        cell.CalendarDayButtonMouseUp += Cell_MouseLeftButtonUp;
                        cell.MouseEnter += Cell_MouseEnter;
                        cell.MouseLeave += Cell_MouseLeave;
                        cell.Click += Cell_Click;
                        MonthView.Children.Add(cell);
                    }
                }
            }

            if (YearView != null)
            {
                GlobalCalendarButton month;
                int count = 0;
                for (int i = 0; i < GlobalCalendar.RowsPerYear; i++)
                {
                    for (int j = 0; j < GlobalCalendar.ColumnsPerYear; j++)
                    {
                        month = new GlobalCalendarButton();

                        if (Owner != null)
                        {
                            month.Owner = Owner;
                            if (Owner.CalendarButtonStyle != null)
                            {
                                month.Style = Owner.CalendarButtonStyle;
                            }
                        }
                        month.SetValue(Grid.RowProperty, i);
                        month.SetValue(Grid.ColumnProperty, j);
                        month.CalendarButtonMouseDown += Month_CalendarButtonMouseDown;
                        month.CalendarButtonMouseUp += Month_CalendarButtonMouseUp;
                        month.MouseEnter += Month_MouseEnter;
                        month.MouseLeave += Month_MouseLeave;
                        YearView.Children.Add(month);
                        count++;
                    }
                }
            }
        }