Example #1
0
 public void setDayLabels(params string[] events)
 {
     DayLabels.Clear();
     foreach (string e in events)
     {
         DayLabels.Add(e);
     }
 }
Example #2
0
        public void updateHandler(Object sender, NotifyCollectionChangedEventArgs eArgs)
        {
            DayCollection collection = (DayCollection)GetValue(DaysProperty);

            contentGrid.Children.Clear();

            contentGrid.RowDefinitions.Clear();

            RowDefinition row = new RowDefinition();

            row.Height = GridLength.Auto;
            contentGrid.RowDefinitions.Add(row);

            contentGrid.Children.Add(monthLabel);

            row        = new RowDefinition();
            row.Height = GridLength.Auto;
            contentGrid.RowDefinitions.Add(row);

            for (int i = 0; i < DayLabels.Count(); ++i)
            {
                dayLabels[i].Content = DayLabels[i];
                contentGrid.Children.Add(dayLabels[i]);
            }

            if (collection.Count == 0)
            {
                return;
            }

            for (int i = 0; i < numRows; ++i)
            {
                row        = new RowDefinition();
                row.Height = new GridLength(1, GridUnitType.Star);
                contentGrid.RowDefinitions.Add(row);
            }


            for (int i = 0; i < collection.Count; ++i)
            {
                Day d = collection.ElementAt(i);

                Button dayLabel = new Button();
                dayLabel.Tag     = d.Id;
                dayLabel.Content = d.Label;
                dayLabel.Click  += OnEventClick;
                if (d.IsToday)
                {
                    dayLabel.BorderThickness = new Thickness(6);
                    dayLabel.BorderBrush     = new SolidColorBrush(Colors.Red);
                }
                if (!d.IsThisMonth)
                {
                    dayLabel.Foreground = new SolidColorBrush(Colors.DarkGray);
                }
                if (d.HasEvents)
                {
                    dayLabel.Style = (Style)Resources["HighlightedMonthDayLabel"];
                }
                else
                {
                    dayLabel.Style = (Style)Resources["MonthDayLabel"];
                }
                Grid.SetRow(dayLabel, d.Row + 2);
                Grid.SetColumn(dayLabel, d.Col);

                contentGrid.Children.Add(dayLabel);
            }
        }