This is a migrated thread and some comments may be shown as answers.

How to change the backcolor for each date

13 Answers 197 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
ranjani
Top achievements
Rank 1
ranjani asked on 06 Feb 2009, 06:09 AM

I need to set backcolor for each date ,how to set background color at run time for calendar control .

13 Answers, 1 is accepted

Sort by
0
Serrin
Top achievements
Rank 1
answered on 06 Feb 2009, 06:39 PM
I wanted to add to this, a feature request of sorts, is there any chance we are going to be seeing Special Days (like in the ASP.Net Ajax controls) in the Q1 or Q2 release? :)
0
Vlad
Telerik team
answered on 09 Feb 2009, 07:52 AM
Hello guys,

We already have this! Please check following demo:
http://demos.telerik.com/silverlight/#Calendar/SpecialDays

All the best,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ulrich Fiege
Top achievements
Rank 1
answered on 21 Jul 2010, 06:25 AM
I also interested in this sample but i get a error that this demo is not running in XBAP Mode?
Greetings ...
0
Kaloyan
Telerik team
answered on 23 Jul 2010, 09:12 AM
Hello Ulrich Fiege,

Find the correct link for the xbap online demos.

Regards,
Kaloyan
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
Valentijn
Top achievements
Rank 1
answered on 16 Dec 2010, 03:44 PM
Hi

It seems this link does no longer work:

http://demos.telerik.com/silverlight/#Calendar/SpecialDays

I would like to know more about the special days feature in Silverlight Calendar control.

Valentijn
0
Kaloyan
Telerik team
answered on 21 Dec 2010, 02:04 PM
Hi Valentijn,

You can find a brand new example following this link. It uses a custom style/template selectors applied to the calendar items.

Greetings,
Kaloyan
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Geoffrey
Top achievements
Rank 1
answered on 21 Dec 2010, 03:36 PM
Hi

Thank you for the link.
I have tried it, but i cannot see how i would assign events to the eventscollection from code behind. When i try to assign a name to the eventcollection resource, in code behind at runtime the eventscollection is not instantiated. If i try to create my own eventscollection in code behind and try to  assign in to the templateselector, the templateselector at runtime is also null.

If i don't use code behind it works, otherwise there seems to be no way.

How can i use the  templateselector from code behind?

 

 

 

 

0
Geoffrey
Top achievements
Rank 1
answered on 21 Dec 2010, 04:10 PM
Is there any way you can add days to the calendar that would show up in a different style immediately at runtime?

If you add the days to the eventscollection as in the example and you give it to the daystyleselector, the style will only be updated in the beginning when the calendar is rendered, but it will not update the style when you add events at runtime (for example if someone clicks a date in the calendar).

I need a way to let the user select and deselect dates in the calendar without using CTRL to select multiple dates. Also when a user clicks a date now, all the other days are deselected. Is there anyway to change this behavior? I thought the example using the eventscollection would help me, but the calendar is not update when adding or removing days to the eventsCollection.

Could someone point me in the right direction please?

Thank you
0
Kaloyan
Telerik team
answered on 27 Dec 2010, 10:39 AM
Hi ranjani,

All you have to do is update the DayTemplateSelector or StyleSelector with a new one. You can achieve that by setting it to null and then going back to the old one. You can put this code when a collection changing appears. Let us know if the approach is not clear enough.

Best wishes,
Kaloyan
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Licenses
Top achievements
Rank 1
answered on 13 Jan 2011, 02:10 PM
Hello,

I'm having the same problem. I've done everything as described, but I'm not sure what you mean with the following:

All you have to do is update the DayTemplateSelector or StyleSelector with a new one. You can achieve that by setting it to null and then going back to the old one.

I've tried the following things:
1. In the codebehind: set the DayTemplateSelector of the Calendar control to null, and then back to the same DataTemplateSelector.
2. Remove the DataTemplateSelector from the resources and then add it again.
3. Call Calendar.UpdateLayout()
4. Create a new DataTemplateSelector in codebehind and set this as the DayTemplateSelector.

None of the approaches makes the calendar draw itself again with the correct daytemplates. Is there something I'm missing?

Thankx,
Sodi


0
Valentijn
Top achievements
Rank 1
answered on 13 Jan 2011, 03:28 PM
Hi

For me it was not working too, until i downloaded the latest hotfix. Just look and see if you have the latest version.

best regards

Valentijn
0
Licenses
Top achievements
Rank 1
answered on 13 Jan 2011, 03:48 PM
Hi Valentijn,

For me it seems to work when I set the Template in codebehind to null and than back to its old value. So something like this:

public void UpdateEventsCollection()
        {
            ObservableCollection<CalendarItemDto> newEventsCollection = new EventsCollection();
            newEventsCollection.AddRange(ViewModel.SelectedCalendarItems);
            var templateSelector = calendar.DayTemplateSelector as EventDayTemplateSelector;
            templateSelector.EventsCollection = newEventsCollection as EventsCollection;
            //trigger the SelectTemplate() of the changed TemplateSelector
            var oldTemplate = calendar.Template;
            calendar.Template = null;
            calendar.Template = oldTemplate;
 
        }

How do you trigger that the SelectTemplate of the DayTemplateSelector is fired again?

Thanks,
Sodi
0
Kaloyan
Telerik team
answered on 14 Jan 2011, 02:19 PM
Hello ranjani,

You can also download the 2010-Q3-2010 SP1 that will be launched later today and enjoy the new improvements regarding the other controls.

Regards,
Kaloyan
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
Tags
Calendar
Asked by
ranjani
Top achievements
Rank 1
Answers by
Serrin
Top achievements
Rank 1
Vlad
Telerik team
Ulrich Fiege
Top achievements
Rank 1
Kaloyan
Telerik team
Valentijn
Top achievements
Rank 1
Geoffrey
Top achievements
Rank 1
Licenses
Top achievements
Rank 1
Share this question
or