radcalender control problem

8 posts, 0 answers
  1. sonam
    sonam avatar
    19 posts
    Member since:
    Jan 2011

    Posted 08 Apr 2011 Link to this post

     

    hello Telerik,
     i am using RadCalender control. and i want to implement a scenario. in my scenario i have to show some special dates for a month highlighted.
    for example i want to highlight all those dates in a perticular month on which meetings are scheduled, or those dates on which holidays 
     are falling.
    pls suggest me the way to implement it in silverlight.
  2. sonam
    sonam avatar
    19 posts
    Member since:
    Jan 2011

    Posted 08 Apr 2011 Link to this post

    hello telerik,
    pls do reply soon , i am waiting..its realy very urgent!!!
  3. DevCraft banner
  4. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 11 Apr 2011 Link to this post

    Hi sonam,

    You should  use DayTemplateSelector in order to apply different style to the special days. I've attached an example to demonstrate the approach.

    Hope this helps.

    Greetings,
    Yana
    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
  5. sonam
    sonam avatar
    19 posts
    Member since:
    Jan 2011

    Posted 13 Apr 2011 Link to this post

    hello Telerik,
    thanks a lot for answering it...
    i have implemented my problem in the same way u have suggested.. and it's working well with radcalender.
    but when i tried it in raddatepicker , nothing is getting highlighted.
    my xaml for raddatepicker is-
    <UserControl xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"  x:Class="datepickerexp.MainPage"
        xmlns:local="clr-namespace:datepickerexp"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400">
      <Grid x:Name="LayoutRoot" Background="White">
            <Grid.Resources>
                <local:CustomTemplateSelector x:Key="CustomTemplateSelector">
                    <local:CustomTemplateSelector.SpecialTemplate>
                <DataTemplate>
                <TextBlock Text="{Binding Text}" Foreground="Red" FontWeight="Bold" />
            </DataTemplate>
                    </local:CustomTemplateSelector.SpecialTemplate>
                </local:CustomTemplateSelector>
                  
            </Grid.Resources>
            <telerik:RadDatePicker x:Name="dpAsofDate" 
                                   Grid.Row="0"
                                   DayTemplate="{x:Null}"
                                   Grid.Column="4" 
                                   Grid.ColumnSpan="3" 
                                   Width="100" Height="25" 
                                   HorizontalAlignment="Left"
                                   DateSelectionMode="Day" 
                                   IsDropDownOpen="True"
                                   DayTemplateSelector="{StaticResource CustomTemplateSelector}">
                <telerik:RadDatePicker.CalendarStyle>
                    <Style TargetType="telerik:RadCalendar"/>    </telerik:RadDatePicker.CalendarStyle>
            </telerik:RadDatePicker>
               </Grid>
    </UserControl>

    and my CustomTemplateSelector.cs is-
    namespace datepickerexp
    {
        public class CustomTemplateSelector : DataTemplateSelector
        {
            public DataTemplate SpecialTemplate
            {
                get;
                set;
            }
      
            public override DataTemplate SelectTemplate(object item, DependencyObject container)
            {
                List<DateTime> lsdate = GetDate();
                CalendarButtonContent content = item as CalendarButtonContent;
                if (content != null)
                {
                     
                    foreach (DateTime dt in lsdate)
                    {
                        if (content.Date.Day == dt.Day && content.Date.Month == dt.Month && content.Date.Year == dt.Year)
                        {
                            return this.SpecialTemplate;
      
                        }
                    }
                }
                return base.SelectTemplate(item, container);
            }
            public List<DateTime> GetDate()
            {
                List<DateTime> lsdateTime = new List<DateTime>();
                lsdateTime.Add(DateTime.Today.Date);
                DateTime dt = new DateTime(2011, 04, 17);
                DateTime dt1 = new DateTime(2011, 04, 15);
                DateTime dt2 = new DateTime(2011, 05, 26);
                lsdateTime.Add(dt); lsdateTime.Add(dt1); lsdateTime.Add(dt2);
                return lsdateTime;
      
            }
        }
    }
    please look after the issue as soon as possible..thanks in advance!!!

  6. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 14 Apr 2011 Link to this post

    Hi sonam,

    You should set the CustomTemplateSelector like this:

    <Grid x:Name="LayoutRoot"  Background="White">
        <Grid.Resources>
            <local:CustomTemplateSelector x:Key="CustomTemplateSelector">
                <local:CustomTemplateSelector.SpecialTemplate>
                    <DataTemplate>
                        <TextBlock Text="{Binding Text}" Foreground="Red" FontWeight="Bold" />
                    </DataTemplate>
                </local:CustomTemplateSelector.SpecialTemplate>
            </local:CustomTemplateSelector>
     
        </Grid.Resources>
        <telerik:RadDatePicker x:Name="dpAsofDate"
                                Grid.Row="0"                            
                                Grid.Column="4"
                                Grid.ColumnSpan="3"
                                Width="100" Height="25"
                                HorizontalAlignment="Left"
                                DateSelectionMode="Day"
                                IsDropDownOpen="True" >
            <telerik:RadDatePicker.CalendarStyle>
                <Style TargetType="telerik:RadCalendar">
                    <Setter Property="DayTemplateSelector" Value="{StaticResource CustomTemplateSelector}" />
                </Style>
            </telerik:RadDatePicker.CalendarStyle>
        </telerik:RadDatePicker>
    </Grid>

    Try it and let us know the result.

    Kind regards,
    Yana
    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
  7. sonam
    sonam avatar
    19 posts
    Member since:
    Jan 2011

    Posted 15 Apr 2011 Link to this post

    Hi Telerik,
     yes your solution is working well ..but i need some more help in it.
    actualy when the calender appear on clicking the raddatepicker ,a vertical column is also appeared which is highlighted by default .i want to disappear it..
    how can i acheive it?
  8. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 15 Apr 2011 Link to this post

    Hi sonam,

    Could you please clarify which vertical column you mean? If it's the week number column, it can be easily removed like this:

    <telerik:RadDatePicker>
        <telerik:RadDatePicker.CalendarStyle>
            <Style TargetType="telerik:RadCalendar">
                <Setter Property="DayTemplateSelector" Value="{StaticResource CustomTemplateSelector}" />
                <Setter Property="AreWeekNumbersVisible" Value="False" />
            </Style>
        </telerik:RadDatePicker.CalendarStyle>
    </telerik:RadDatePicker>


    Best wishes,
    Yana
    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
  9. Anup
    Anup avatar
    13 posts
    Member since:
    Aug 2011

    Posted 10 May 2013 Link to this post

    Hello Telerik,


    I have a scenario where I want to Book a Day and it should change accordingly...
    can you please help on this...as soon as possible.

    Regards,
    Anup Shah. 
Back to Top
DevCraft banner