Hi!
I have styled some special slots to display saturdays and sundays with a different background color in the month view.
But in the last week of the year, the special slots are not drawn, see attaced image.
It does not matter if the year ends on a sunday or not, its always the last week that is missing.
I have tried with and without the RecursUntil property with no result.
This is my code:
Regards,
HÃ¥kan
I have styled some special slots to display saturdays and sundays with a different background color in the month view.
But in the last week of the year, the special slots are not drawn, see attaced image.
It does not matter if the year ends on a sunday or not, its always the last week that is missing.
I have tried with and without the RecursUntil property with no result.
This is my code:
public
static
ObservableCollection<Slot> SetupSpecialSlots(
bool
readOnly, DateTime? start =
null
, DateTime? end =
null
)
{
ObservableCollection<Slot> specialSlots =
new
ObservableCollection<Slot>();
if
(!start.HasValue)
start = CalendarUtility.GetFirstDateOfYear();
if
(!end.HasValue)
end = CalendarUtility.MergeDateAndTime(CalendarUtility.GetFirstDateOfYear(),
new
TimeSpan(23, 59, 59));
Slot slot =
null
;
slot = CreateSpecialSlot(
new
SaturdayOccurence(), start.Value, end.Value, readOnly);
slot.RecurrencePattern =
new
RecurrencePattern(
null
, RecurrenceDays.Saturday, RecurrenceFrequency.Weekly, 1,
null
,
null
);
specialSlots.Add(slot);
slot = CreateSpecialSlot(
new
SundayOccurence(), start.Value, end.Value, readOnly);
slot.RecurrencePattern =
new
RecurrencePattern(
null
, RecurrenceDays.Sunday, RecurrenceFrequency.Weekly, 1,
null
,
null
);
specialSlots.Add(slot);
return
specialSlots;
}
<
util:CustomSpecialSlotStyleSelector
x:Key
=
"TimeCalendarSpecialSlotStyleSelectorMonthView"
>
<
util:CustomSpecialSlotStyleSelector.DefaultStyle
>
<
Style
TargetType
=
"telerik:HighlightItem"
>
<
Setter
Property
=
"Margin"
Value
=
"0,-47,0,0"
/>
<
Setter
Property
=
"Background"
Value
=
"{x:Null}"
/>
</
Style
>
</
util:CustomSpecialSlotStyleSelector.DefaultStyle
>
<
util:CustomSpecialSlotStyleSelector.ReadOnlyStyle
>
<
Style
TargetType
=
"telerik:HighlightItem"
>
<
Setter
Property
=
"Margin"
Value
=
"0,-47,0,0"
/>
<
Setter
Property
=
"Background"
Value
=
"{x:Null}"
/>
</
Style
>
</
util:CustomSpecialSlotStyleSelector.ReadOnlyStyle
>
<
util:CustomSpecialSlotStyleSelector.SaturdayStyle
>
<
Style
TargetType
=
"telerik:HighlightItem"
>
<
Setter
Property
=
"Margin"
Value
=
"0,-47,0,0"
/>
<
Setter
Property
=
"Background"
Value
=
"{StaticResource PaleBlueBrush}"
/>
</
Style
>
</
util:CustomSpecialSlotStyleSelector.SaturdayStyle
>
<
util:CustomSpecialSlotStyleSelector.SundayStyle
>
<
Style
TargetType
=
"telerik:HighlightItem"
>
<
Setter
Property
=
"Margin"
Value
=
"0,-47,0,0"
/>
<
Setter
Property
=
"Background"
Value
=
"{StaticResource PaleRedBrush}"
/>
</
Style
>
</
util:CustomSpecialSlotStyleSelector.SundayStyle
>
</
util:CustomSpecialSlotStyleSelector
>
public
class
CustomSpecialSlotStyleSelector : ScheduleViewStyleSelector
{
public
Style DefaultStyle {
get
;
set
; }
public
Style ReadOnlyStyle {
get
;
set
; }
public
Style SaturdayStyle {
get
;
set
; }
public
Style SundayStyle {
get
;
set
; }
public
override
Style SelectStyle(
object
item, DependencyObject container, ViewDefinitionBase activeViewDefinition)
{
if
(item
is
DefaultOccurence)
return
this
.DefaultStyle;
else
if
(item
is
ReadOnlyOccurence)
return
this
.ReadOnlyStyle;
else
if
(item
is
SundayOccurence)
return
this
.SundayStyle;
else
if
(item
is
SaturdayOccurence)
return
this
.SaturdayStyle;
return
base
.SelectStyle(item, container, activeViewDefinition);
}
}
Regards,
HÃ¥kan