Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Windows Phone 7 > Calendar > Display Image on certain days

Answered Display Image on certain days

Feed from this thread
  • Posted on May 7, 2012 (permalink)

    Hi,

    How should it work to display Images on certain days?.  So far I have this but it displays the image on ever day:

                        <telerikInput:RadCalendar.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="5">
                                    <Image Source="/Images/Add.png" Width="24" Height="24" Name="calIcon" />
                                    <TextBlock Text="{Binding DetailText}" FontSize="7" MaxHeight="25" VerticalAlignment="Top" Margin="0,-2,0,0" />
                                    <TextBlock Text="{Binding Text}" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
                                </Grid>
                            </DataTemplate>
                        </telerikInput:RadCalendar.ItemTemplate>

    The Text displays correctly on the days I want using the standard Appointment approach, but how to control the image??  Its not really clear how this is working.

    Thanks!

    Reply

  • Valentin.Stoychev Valentin.Stoychev admin's avatar

    Posted on May 8, 2012 (permalink)

    Hello,

    you need to use a TemplateSelector for this. Please check this help article:
    http://www.telerik.com/help/windows-phone/radcalendar-features-specialdays.html

    Regards,
    Valentin.Stoychev
    the Telerik team

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

    Reply

  • Posted on May 8, 2012 (permalink)

    Hi,

    Well, I'm still stuck....  The example just states to highlight weekends.  I need to highlight dates that have actual data.  Appointments that I have made.  Its not at all clear how this should work. I don't find a working way to check if there is actual data. Do you have some kind of working example for this?

    thanks!

    Reply

  • Kiril Stanoev Kiril Stanoev avatar

    Posted on May 9, 2012 (permalink)

    Hello Steven,

    Thank you for contacting us. I've prepared a small project which demonstrates how to use a DataTemplateSelector in the context of RadCalendar. Please take a look at it and let me know if you find anything unclear or you need further explanation. I'd be glad to assist you.

    Kind regards,
    Kiril Stanoev
    the Telerik team

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

    Attached files

    Reply

  • Posted on May 9, 2012 (permalink)

    Hi,

    Ok.... its getting clearer, but say I have some data like:

                radCalendar.AppointmentSource = new SampleAppointmentSource();


           public class SampleAppointmentSource : AppointmentSource
            {
                public SampleAppointmentSource()
                {
                }
                public override void FetchData(DateTime startDate, DateTime endDate)
                {
                    AllAppointments.Clear();
                    DateTime start = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
                    DateTime end = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 2);
                    IList<ViewEntry> list = DBHelper.GetReadOnlyEntrysForDate(startDate, endDate);
                    for (int i = 0; i < list.Count(); i++)
                    {
                        ViewEntry e = list.ElementAt(i);
                        
                            AllAppointments.Add(new CalendarAppointment()
                            {
                                StartDate = e.StartDate.AddMinutes(1),
                                EndDate = e.StartDate.AddMinutes(1),
                                Subject = e.GetText();
                            });
                    }

    So I am adding my own entries from the database.  And these are displayed on the given days on the calendar.

    Also for these appointments I want to display a little icon as well as the text.So I need my template.

    In the template version supplied I don't quite see how to access the appointment information.

    If I query  CalendarButtonContentInfo info = item as CalendarButtonContentInfo;

    The appointments in "info" are null, there are no appointments to query, kind of odd as they are displayed.  

    info.Appointments.Count  is always 0.

    Should the appointments be available in the CalendarButtonContentInfo ??  Perhaps I messed it up there?

    Its like I need to display only on those days based upon my database entries, at the moment I don't see how to bind the template to the data.  The only solution i have at the moment is making query in the database in the Template, but this rather silly as I have to make a ton of queries every time the template is called (31 times!).

    I'm sure i messed up somewhere...

    Thanks!
    S.


    Reply

  • Posted on May 10, 2012 (permalink)

    aggh, no answer, in the meantime I hacked it like this (not really a good solution):

                            AllAppointments.Add(new CalendarAppointment()
                            {
                                StartDate = e.StartDate.AddMinutes(1),
                                EndDate = e.StartDate.AddMinutes(1),
                                Subject = "Images/frog_sad.png" // FAKE IT to get the image and no text
                            });


                        <telerikInput:RadCalendar.ItemTemplate>
                            <DataTemplate>
                                <Grid Margin="5">
                                    <Image Source="{Binding DetailText}" Width="24" Height="24" Visibility="Visible" Name="calIcon" />
                                    <TextBlock Text="{Binding Text}" FontSize="17" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
                                </Grid>
                            </DataTemplate>
                        </telerikInput:RadCalendar.ItemTemplate>


    Now i got my icon there... OK, no text now :-(

    Reply

  • Answer Todor Todor admin's avatar

    Posted on May 14, 2012 (permalink)

    Hello Steven,

    This is in fact an issue in the current version of RadCalendar and we will try to fix it for our future releases. For now, you can use your AppointmentSource in the TemplateSelector and check if there are any appointments for the current date (info.Date) and based on that you can return the relevant template.

    I have updated your account with some telerik points for reporting this issue. Let me know if I can assist you furtherer.

    Kind regards,
    Todor
    the Telerik team

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

    Reply

  • Posted on May 14, 2012 (permalink)

    Hi,

    Thanks for your reply.  My hack solution works for me at the moment.  I leave the text off and just display this icon.

    thanks!
    Steven.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Windows Phone 7 > Calendar > Display Image on certain days