Hi Telerik,
I've had a somewhat similar thread sometime ago, but here is what I need to do:
Basically what I want to achieve is to add some custom object to the CalendarButtonContent for my DataTemplate to access.
I have created a template selector and finding that the given date is a Holiday, then returning my HolidayTemplate.
In XAML I would like my template to achieve something like the following (where CustomText is the object somehow added to the CalendarButtonContent or otherwise referenced):
I would be happy if I could somehow from my template just access some custom data outside the scope of the CalendarButtonContent, i.e. some static public data, if this would somehow be possible, but I guess that has not really anything to do with your Calendar control :)
Thanks in advance!
Best regards,
Kasper Schou
I've had a somewhat similar thread sometime ago, but here is what I need to do:
Basically what I want to achieve is to add some custom object to the CalendarButtonContent for my DataTemplate to access.
I have created a template selector and finding that the given date is a Holiday, then returning my HolidayTemplate.
public
class
CalendarButtonTemplateSelector : DataTemplateSelector
{
public
override
DataTemplate SelectTemplate(
object
item, DependencyObject container)
{
CalendarButtonContent content = item
as
CalendarButtonContent;
if
(content !=
null
&& content.ButtonType == CalendarButtonType.Date)
{
if
(CentralCalendarWindow.CalendarViewItems !=
null
&& CentralCalendarWindow.CalendarViewItems.Exists(c => c.Date == content.Date))
{
CalendarViewItem calendarViewItem = CentralCalendarWindow.CalendarViewItems.Find(c => c.Date == content.Date);
if
(calendarViewItem.IsHoliday)
{
return
HolidayTemplate;
}
}
}
}
}
In XAML I would like my template to achieve something like the following (where CustomText is the object somehow added to the CalendarButtonContent or otherwise referenced):
<
DataTemplate
>
<
StackPanel
>
<
TextBlock
Text
=
"{Binding Text}"
/>
<
TextBlock
Text
=
"{Binding CustomText}"
/>
</
StackPanel
>
</
DataTemplate
>
I would be happy if I could somehow from my template just access some custom data outside the scope of the CalendarButtonContent, i.e. some static public data, if this would somehow be possible, but I guess that has not really anything to do with your Calendar control :)
Thanks in advance!
Best regards,
Kasper Schou