Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Calendar > Silverlight Calendar DayTemplateSelector

Not answered Silverlight Calendar DayTemplateSelector

Feed from this thread
  • Burbank avatar

    Posted on Nov 23, 2011 (permalink)

    I am trying to use the DayTemplateSelector to Select special days on the Calendar but I am having problems because I am getting my data (dates) from Ria Service. The Asynchronous nature of obtaining data makes it difficult to get the dates for SelectTemplate method . Any help on this will be highly appreciated. Below is part of the code:

     public class CustomDayTemplateSelector : DataTemplateSelector
        {
            private WarrantyContext _Context = null;
            private List<Inspection> _Inpections;

            public CustomDayTemplateSelector()
            {
                _Context = new WarrantyContext();
                _Inpections = new List<Inspection>();
                LoadOperation<Inspection> loadOp = _Context.Load(_Context.GetInspectionsQuery());
                loadOp.Completed += new EventHandler(LoadAppointments_Completed);
            }

            public override DataTemplate SelectTemplate(object item, DependencyObject container)
            {
                CalendarButtonContent content = item as CalendarButtonContent;

                foreach (var a in _Inpections)
                {
                    if (a.StartDate == content.Date)
                    {
                        return this.ActivityTemplate;
                    }
                }

                return DefaultTemplate;
            }

            public DataTemplate DefaultTemplate { get; set; }
            public DataTemplate ActivityTemplate { get; set; }    

            private void LoadAppointments_Completed(object sender, EventArgs e)
            {
                foreach (var inspection in _Context.Inspections)
                {
                    Inspection appointment = new Inspection();
                    appointment.StartDate = inspection.StartDate;
                    appointment.EndDate = inspection.EndDate;
                    appointment.UserId = inspection.UserId;
                    _Inpections.Add(appointment);
                }
            }

        }

    Reply

  • Ivo Ivo admin's avatar

    Posted on Nov 28, 2011 (permalink)

    Hi Burbank,

    This can be achieved by reseting the template when your appointments are loaded. You can find an example attached. Into the example SpecialEvent is added on button click and the RadCalendar template is reset.

    All the best,
    Ivo
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

    Reply

  • Burbank avatar

    Posted on Nov 29, 2011 (permalink)

    Thank you Ivo. The explanation and the code sample are very helpful.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Silverlight > Calendar > Silverlight Calendar DayTemplateSelector
Related resources for "Silverlight Calendar DayTemplateSelector"

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