Show only year in ViewHeader

6 posts, 0 answers
  1. RSquired
    RSquired avatar
    12 posts
    Member since:
    Apr 2012

    Posted 17 Mar 2015 Link to this post


    In month view calendar header shows as "March - 2015" ... How to show only  "2015" ?
  2. Geri
    Admin
    Geri avatar
    60 posts

    Posted 18 Mar 2015 Link to this post

    Hi Roshan,

    Thank you for contacting us.

    You can achieve the desired look by modifying the format of the MonthViewHeader property as follows:

    <telerik:RadCalendar MonthViewHeaderFormat="yyyy" />

    Hope this helps.

    Regards,
    Geri
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. RSquired
    RSquired avatar
    12 posts
    Member since:
    Apr 2012

    Posted 19 Mar 2015 in reply to Geri Link to this post

    Thanks Geri.. 

    Please refer to the picture attached. there are both calendarHeader and mothsheaders. by adding 
    MonthViewHeaderFormat="yyyy

    Both calendarHeader and  monthHeaders are changing. But I want to change only the top calendar hear to the 'yyyy' format.  
  5. Geri
    Admin
    Geri avatar
    60 posts

    Posted 19 Mar 2015 Link to this post

    Hi Roshan,

    The desired functionality does not come built-in in the RadCalendar. However, it can be achieved easily by modifying the ControlTemplate of the CalendarHeaderButton. You would need to find the the two TextBlock elements named "BackgroundText" and "ForegroundText" and change the text as needed by using IValueConverter:

    Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource YearConverter}}"

    Hope this helps.

    Regards,
    Geri
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. RSquired
    RSquired avatar
    12 posts
    Member since:
    Apr 2012

    Posted 20 Mar 2015 in reply to Geri Link to this post

    Hi teri

    I have used the style of rad Calendar in a  seperate style file. There  in  <Style x:Key="CalendarHeaderButton" TargetType="Button">   I have 
    <TextBlock x:Name="BackgroundText" Foreground="{StaticResource HeaderTextBackground}" FontWeight="{StaticResource HeaderTextFontWeight}" HorizontalAlignment="Center" Margin="0 2 0 0" Text="{TemplateBinding Content}" VerticalAlignment="Center" />
                           <TextBlock x:Name="ForegroundText" Foreground="{StaticResource HeaderTextForeground}" FontWeight="{StaticResource HeaderTextFontWeight}" HorizontalAlignment="Center" Margin="0 1 0 1" Text="{TemplateBinding Content}" VerticalAlignment="Center"/>

    How can I add the converter there. It says " property converter was not found in type 'templatebinding'"

    Thank you..
  7. Geri
    Admin
    Geri avatar
    60 posts

    Posted 23 Mar 2015 Link to this post

    Hello Roshan,

    In order to use the value converter, you need to replace TemplateBinding with Binding and set the RelativeSource as shown in the code below:

    Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource YearConverter}}"

    Hope this helps.

    Regards,
    Geri
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
DevCraft banner