How can I change the background colour of the day buttons in code? I can see how to change the 'special day' foreground text colour but I want to change the background colour of the whole button not just the text. I'm guessing it has something to do with changing the button style but I cannot work out how to alter the style in code.
Andrew
Andrew
12 Answers, 1 is accepted
0
Hi Andrew,
Kaloyan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
You have to define your own DayButtonStyle or DayButtonStyleSelector to achieve the desired result. Attached is a sample app, that might help you in resolving your case.
All the best,Kaloyan
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Ulrich Fiege
Top achievements
Rank 1
answered on 14 Jul 2010, 12:34 PM
Hello, i also need to change the backcolor from the day buttons.
I try'd to run this sample but with no success using current version Q1,SP2/0712.
Is it possible to set backgound color in other simple way without huge templates?
greetings ...
I try'd to run this sample but with no success using current version Q1,SP2/0712.
Is it possible to set backgound color in other simple way without huge templates?
greetings ...
0
soporte pasiona
Top achievements
Rank 1
answered on 15 Jul 2010, 11:23 AM
I also have the same issue with this sample, the current Silverlight RADControls (version 2010.2.714.1040) do not fire the SelectStyle event.
0
Hello,
Ulrich, there is no easier way than creating a selector.
Soprote, can you send some example code you are using. The selector should work. We even have some examples that customize the different days in our examples for the calendar.
Greetings,
Panayot
the Telerik team
Ulrich, there is no easier way than creating a selector.
Soprote, can you send some example code you are using. The selector should work. We even have some examples that customize the different days in our examples for the calendar.
Greetings,
Panayot
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ulrich Fiege
Top achievements
Rank 1
answered on 21 Jul 2010, 06:56 AM
Thank you for your answer, but i have no code and i look how to slove this.
I need to change the background-color from some defined dates in code behind.
Here is some code from ASP.net using also telerik calendar what we try to translate into silverlight.
If
EventList
Is
Nothing
=
False
Then
Dim
objExistingDates
As
New
List(Of Telerik.Web.UI.RadCalendarDay)
For
i
As
Integer
= 0
To
EventList.Length - 1
Dim
SD
As
New
Telerik.Web.UI.RadCalendarDay
SD.
Date
= EventList(i).eventTime
SD.ItemStyle.BackColor = Drawing.Color.Orange
objExistingDates.Add(SD)
Next
i
cDateTo.SpecialDays.AddRange(objExistingDates.ToArray)
End
If
How can we do this in Silverlight using radcalendar?
Thank you and greetings ...
0
Hi Ulrich Fiege,
I am attaching a project that displays how this change can be done in Silverlight. It uses a simple StyleSelector that will alter the day buttons. The present CalendarButton ControlTemplate does not implement TemplateBindings for Background, Foreground and BorderThickness. We will make sure to have this fixed in one of our internal builds.
All the best,
Panayot
the Telerik team
I am attaching a project that displays how this change can be done in Silverlight. It uses a simple StyleSelector that will alter the day buttons. The present CalendarButton ControlTemplate does not implement TemplateBindings for Background, Foreground and BorderThickness. We will make sure to have this fixed in one of our internal builds.
All the best,
Panayot
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ulrich Fiege
Top achievements
Rank 1
answered on 25 Jul 2010, 04:31 PM
Thank you for the example. I have the problem to set the dates from code manually like in my sample above and not automaticly
like in this sample from the app.cs. Can you give me please a hint to slove this issue.
Thank you ... and greetings ...
like in this sample from the app.cs. Can you give me please a hint to slove this issue.
Thank you ... and greetings ...
0
Hello Ulrich,
You want to change the dates from code like change the month the calendar is displaying or change the content of each button from code behind? Can you give me more information what you are trying to achieve or perhaps attach a small screenshot with the desired look of the calendar and what you want to modify in code?
Regards,
Panayot
the Telerik team
You want to change the dates from code like change the month the calendar is displaying or change the content of each button from code behind? Can you give me more information what you are trying to achieve or perhaps attach a small screenshot with the desired look of the calendar and what you want to modify in code?
Regards,
Panayot
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Bo Kristensen
Top achievements
Rank 1
answered on 27 Jul 2010, 11:47 AM
I would like to change background on specific dates programmaticly. So what I want to accomplish is a property eg. radCalendar.DifferentStyledDates that works more or less the same as radCalendar.SelectedDates.
Your example only shows how to change for the entire calendar and it is not changeable on events from other ui controls.
Is that possible?
Your example only shows how to change for the entire calendar and it is not changeable on events from other ui controls.
Is that possible?
0
Hi Bo Kristensen,
This behavior is not supported out-of-the-box. You can extend the RadCalendar and create additional collection that will keep these custom dates and an attached behavior that you can use to set the background of the buttons. The behavior should do something like parent-of-type to find the RadCalendar and then listen for changes to your collection. When it changes the behavior should update the button's background. This solution is as hard as building your own new control.
Best wishes,
Panayot
the Telerik team
This behavior is not supported out-of-the-box. You can extend the RadCalendar and create additional collection that will keep these custom dates and an attached behavior that you can use to set the background of the buttons. The behavior should do something like parent-of-type to find the RadCalendar and then listen for changes to your collection. When it changes the behavior should update the button's background. This solution is as hard as building your own new control.
Best wishes,
Panayot
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Scott
Top achievements
Rank 1
answered on 24 Aug 2011, 12:46 AM
Is there a better way to change the backgound of a day with a newer release or should I still use the technique in the radcalendar-custmobackgrounds.zip example?
0
Hello Scott,
The RadCalendar control does not bear significant changes since 2010 Q2. Please, use the approach suggested in the sample. You can just clean up the xaml a little bit: remove the CalendarButtonStyle from MainPage. It was added for the purpose of taking advantage of TemplateBindings. These TemplateBindings are currently implemented in the template of RadCalendar, so the style is not needed anymore.
I hope this helps.
Regards,
Dani
the Telerik team
The RadCalendar control does not bear significant changes since 2010 Q2. Please, use the approach suggested in the sample. You can just clean up the xaml a little bit: remove the CalendarButtonStyle from MainPage. It was added for the purpose of taking advantage of TemplateBindings. These TemplateBindings are currently implemented in the template of RadCalendar, so the style is not needed anymore.
<
UserControl.Resources
>
<
local:CalendarButtonStyleSelector
x:Key
=
"StyleSelector"
>
<
local:CalendarButtonStyleSelector.EvenStyle
>
<
Style
TargetType
=
"calendar:CalendarButton"
>
<
Setter
Property
=
"Background"
Value
=
"Red"
/>
</
Style
>
</
local:CalendarButtonStyleSelector.EvenStyle
>
<
local:CalendarButtonStyleSelector.OddStyle
>
<
Style
TargetType
=
"calendar:CalendarButton"
>
<
Setter
Property
=
"Background"
Value
=
"Green"
/>
</
Style
>
</
local:CalendarButtonStyleSelector.OddStyle
>
</
local:CalendarButtonStyleSelector
>
</
UserControl.Resources
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
telerik:RadCalendar
DayButtonStyleSelector
=
"{StaticResource StyleSelector}"
DayButtonStyle
=
"{x:Null}"
Margin
=
"8,34,0,0"
HorizontalAlignment
=
"Left"
VerticalAlignment
=
"Top"
/>
</
Grid
>
I hope this helps.
Regards,
Dani
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>