This question is locked. New answers and comments are not allowed.
public class EventDayTemplateSelector : DataTemplateSelector { public EventDayTemplateSelector() { if (_eventsCollection == null) _dataCollection = GenerateDayCollection.GetDateTimeCollection(); } public override DataTemplate SelectTemplate(object item, DependencyObject container) { CalendarButtonContent content = item as CalendarButtonContent; foreach (DateTime d in this._dataCollection) { if (d == content.Date) return CreateTemplate(Colors.Red); } return base.SelectTemplate(item, container); } private DataTemplate CreateTemplate(Color? colors) { string color = "Black"; string weight = "Normal"; if (colors != null){ color = colors.ToString(); weight = "Bold"; } if (colors == Colors.Black){ color = "Black"; weight = "Normal"; } DataTemplate dt = new DataTemplate(); string xaml = @"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""> <TextBlock FontWeight=""" + weight + @""" Foreground=""" + color + @""" Text=""{Binding Text}""/></DataTemplate>"; return (DataTemplate)System.Windows.Markup.XamlReader.Load(xaml); } private ObservableCollection<DateTime> _dataCollection; public ObservableCollection<DateTime> DataCollection { get { return this._dataCollection; } set { this._dataCollection = value; } } }