Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Calendar > Change day button background

Not answered Change day button background

Feed from this thread
  • Andrew avatar

    Posted on Jan 4, 2010 (permalink)

    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

    Reply

  • Kaloyan Kaloyan admin's avatar

    Posted on Jan 5, 2010 (permalink)

    Hi Andrew,

    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.

    Reply

  • Ulrich Fiege avatar

    Posted on Jul 14, 2010 (permalink)

    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 ... 
     

    Reply

  • soporte pasiona avatar

    Posted on Jul 15, 2010 (permalink)

    I also have the same issue with this sample, the current Silverlight RADControls (version 2010.2.714.1040) do not fire the SelectStyle event.

    Reply

  • Pana Pana admin's avatar

    Posted on Jul 19, 2010 (permalink)

    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
    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

    Reply

  • Ulrich Fiege avatar

    Posted on Jul 21, 2010 (permalink)


    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
    In this case we define a special color to a range of dates in code behind.
    How can we do this in Silverlight using radcalendar?
    Thank you and greetings ...

    Reply

  • Pana Pana admin's avatar

    Posted on Jul 23, 2010 (permalink)

    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
    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

    Reply

  • Ulrich Fiege avatar

    Posted on Jul 25, 2010 (permalink)

    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 ...

    Reply

  • Pana Pana admin's avatar

    Posted on Jul 26, 2010 (permalink)

    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
    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

    Reply

  • Bo Kristensen avatar

    Posted on Jul 27, 2010 (permalink)

    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?

    Reply

  • Pana Pana admin's avatar

    Posted on Jul 29, 2010 (permalink)

    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
    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

    Reply

  • Scott avatar

    Posted on Aug 23, 2011 (permalink)

    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?

    Reply

  • Dani Dani admin's avatar

    Posted on Aug 29, 2011 (permalink)

    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.

    <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 >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Calendar > Change day button background
Related resources for "Change day button background"

Silverlight Calendar Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  ]