Reputation: 115
How can I change the color of today's background in CalendarView?
Always thank you in advance..!
Upvotes: 1
Views: 968
Reputation: 10227
The style key you need to override to customize the color used when IsTodayHighlighted="True" is SystemControlHighlightAccentBrush
<CalendarView>
<CalendarView.Resources>
<SolidColorBrush x:Key="SystemControlHighlightAccentBrush" Color="Green" />
</CalendarView.Resources>
</CalendarView>
Upvotes: 5
Reputation: 5276
You can achieve this with not much of an effort using c#. And to be honest it's much better than writing up a style for such a trivial thing. Below is how you do it:
CalendarViewDayItemChanging
event of the CalendarView
private void CalendarView_CalendarViewDayItemChanging(CalendarView sender, CalendarViewDayItemChangingEventArgs args)
{
if (args.Item.Date.Date.Equals(DateTime.Now.Date))
args.Item.Background = new SolidColorBrush(Colors.Yellow);
}
While your XAML declaration looks like below:
<CalendarView CalendarViewDayItemChanging="CalendarView_CalendarViewDayItemChanging"/>
Upvotes: 2