Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
XamMonthCalendar refreshing CalendarDayStyleSelector
posted

Hi,

I'm trying to use the CalendarDayStyleSelector in the XamMonthCalendar control. i want to highlight the dates that are in a observable collection in my view model. i've written a style selector and this is referenced using

<UserControl.Resources>

<local:DateStyleSelector x:Key="dayStyle" />

</UserControl.Resources>

...

CalendarDayStyleSelector="{DynamicResource dayStyle}"

and in the code behind

Style dayStyle = new Style(typeof(Control));

var date = (CalendarDay) item;

var viewModel = (HolidaysViewModel) date.DataContext;

if (viewModel.DatesForSelectedFinCentres.Contains(date.StartDate))

{

dayStyle.Setters.Add(new Setter(Control.BackgroundProperty, Brushes.Wheat));

}

this works when you change month in the calendar as the styles are reset.

is there a way to make the styleselector refresh when the observable collection changes

many thanks

Parents Reply Children
No Data