Hi there
i have a list of datetime. Now, every day in the datetime-list should get a background color in the xamcalendar.
Could you please help me out here?
regards
Cloud
Hello Cloud,
Thank you for your post. I have been looking into it and I created a sample project for you with the functionality you want. Basically I handled the CalendarDay’s Loaded event and in its handler I check if the List with the dates contains the loading day and if it does I changed its Background. Please let me know if this helps you or you need further assistance on this matter.
Looking forward for your reply.
thank you for the sample. that is almost what i need.
some little point is just not the way i want. is it possible to set the event of the eventsetter to the event of another control? because in my project the event should be fired when my xamdatagrid activate a record. that would be awesome.
ist it possible to do that somehow?
I have modified the sample I sent you before, so now it has the functionality you want. Basically I add the dates to the DisabledDates collection of the XamMonthCalendar and I created a Style for the CalendarDay with a Trigger to change the background if the date is disabled. I used this approach because of the virtualization of the CalendarDay elements.
Hope this helps you.
that looks good so far.
one last matter: is it possible to get the days displayed in the monthcalendar?
because now i got to every datetime a string with a certain code.
and the monthcalendar should now display all the days in the datetime-list and depend on the string-code the backgroud color should be set.
e.g:
2012-10-10 hast the code "Holiday" and because of that the background-color of this day should be green.
can i realize something like that?
best regards
cloud
I am just checking if you got this worked out or you still require any assistance or clarification on the matter.
yes thanks i solved it. i had one little mistake in my code.
everything u said was working.
I have modified the sample I sent you before and everything seems to work ok on my side. If the sample doesn’t satisfies all your needs feel free to modify it, so it reproduces your behavior and send it back to me for further investigation.
but one problem still exists.
i´m using this xaml to set the color of my calendardays:
<igEditors:XamMonthCalendar TodayButtonVisibility="Hidden" ShowDisabledDaysOfWeek="True" Name="mcMonthCalendar" Language="de-DE"> <igEditors:XamMonthCalendar.Resources> <converter:DateToColor x:Name="dateConverter" x:Key="dateConverter"></converter:DateToColor> <Style TargetType="{x:Type igEditors:CalendarDay}"> <Style.Triggers> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Background" Value="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource dateConverter}}"></Setter> </Trigger> </Style.Triggers> </Style> </igEditors:XamMonthCalendar.Resources> </igEditors:XamMonthCalendar>
and my converter get as value a calendarday and returns the backgroundcolor for that special day.
now i have this scenario:
i set the range of the calendar with 2 datepicker. and when i press a button i set the min and maxdate of my monthcalendar.
the first time i do this the colors where set correctly and all works fine.
but when i now change the datepicker dates (e.g. mindate - 1month) then the colors are not in the right month but one month earlier.
could you imagine why this happens?
Since the DisabledDates Property is read only, it cannot be bound to a source, and you are not able to use a Converter. It seems that the approach I suggested you in my previous posts is the best one for achieving the functionality you want.
i still have one question:
is it possible that every time my disableddates change, to give all this dates to a converter who sets me the borderbrush and the background of the calendardayitem?
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.