This question is locked. New answers and comments are not allowed.
Hello
I am using RadControls in my silverlight application and there is a radcalendar. I would like to display all sundays in a separate color. I tried giving few styles but didnt worked. So please help me with this.
Freddy
I am using RadControls in my silverlight application and there is a radcalendar. I would like to display all sundays in a separate color. I tried giving few styles but didnt worked. So please help me with this.
Freddy
3 Answers, 1 is accepted
0
Accepted
Shinu
Top achievements
Rank 2
answered on 14 Jul 2013, 10:34 AM
Hi Freddy,
This can be achieved by creating a custom StyleSelector and setting it to the DayButtonStyleSelector property of the control. The custom DayButtonStyleSelector that inherits StyleSelector class can be created as follows.
C#:
Next add the namespace in the XAML.
XAML:
Create a StaticResource for the DayButtonStyleSelector and the SpecialStyleSunday Style.
XAML:
Finally set the DayButtonStyleSelector property of the control and set the DayButtonStyle to null in order for the custom DayButtonStyleSelector to be used as follows.
XAML:
Thanks,
Shinu.
This can be achieved by creating a custom StyleSelector and setting it to the DayButtonStyleSelector property of the control. The custom DayButtonStyleSelector that inherits StyleSelector class can be created as follows.
C#:
public class DayButtonStyleSelector : StyleSelector{ public Style SpecialStyleSunday { get; set; } public override Style SelectStyle(object item, DependencyObject container) { CalendarButtonContent content = item as CalendarButtonContent; if (content != null) { if (content.Date.DayOfWeek == DayOfWeek.Sunday && content.ButtonType == CalendarButtonType.Date) { return SpecialStyleSunday; } } return base.SelectStyle(item, container); }}Next add the namespace in the XAML.
XAML:
<UserControl x:Class="CalendarDayButtonStyle.MainPage" ... xmlns:local="clr-namespace:CalendarDayButtonStyle" xmlns:calendar="clr-namespace:Telerik.Windows.Controls.Calendar;assembly=Telerik.Windows.Controls.Input" ...></UserControl>Create a StaticResource for the DayButtonStyleSelector and the SpecialStyleSunday Style.
XAML:
<local:DayButtonStyleSelector x:Key="CustomStyleSelector"> <local:DayButtonStyleSelector.SpecialStyleSunday> <Style TargetType="calendar:CalendarButton"> <Setter Property="Background"> <Setter.Value> <SolidColorBrush Color="Red" Opacity="0.5"/> </Setter.Value> </Setter> </Style> </local:DayButtonStyleSelector.SpecialStyleSunday></local:DayButtonStyleSelector>Finally set the DayButtonStyleSelector property of the control and set the DayButtonStyle to null in order for the custom DayButtonStyleSelector to be used as follows.
XAML:
<telerik:RadCalendar DayButtonStyleSelector="{StaticResource CustomStyleSelector}" DayButtonStyle="{x:Null}"/>Thanks,
Shinu.
0
Freddy
Top achievements
Rank 1
answered on 15 Jul 2013, 09:06 AM
Thanks, I have another requirement to set a custom color on hovering dates in the calendar. So please help me to get it.
0