XF Windows Phone change month info color

5 posts, 1 answers
  1. Yordan
    Yordan avatar
    14 posts
    Member since:
    Jan 2013

    Posted 23 Dec 2015 Link to this post

    Hello,

    I am using Xamarin Forms to make an Windows Phone app. In it I have the Calendar control on one of the pages. The calendar on Windows Phone is on black background. However, In my app I have white background and if the background is white, the top row, which shows the month and the year, is not visible (since it is also white). I have looked through the docs and in the Calendar renderer for Windows Phone, but I could not manage to find a property which can change the aforementioned row's color. Is there some way to achieve this effect?

    Thanks in advance.

    Regards

  2. Yordan
    Yordan avatar
    14 posts
    Member since:
    Jan 2013

    Posted 23 Dec 2015 in reply to Yordan Link to this post

    I have managed to accomplish what I want when I changed the entire app theme to light.

    But still my question stands - is there a way to change the color of the month and year only?
  3. DevCraft banner
  4. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1183 posts

    Posted 28 Dec 2015 Link to this post

    Hi Dancho,

    I cannot be sure which version of Windows Phone you are currently using. This is why I assume you are referring to Windows Phone 8.0. You can achieve your requirement in that platform by customizing the Template of the RadCalendar component as it is stated here. Once you have created your custom template you can apply it to the RadCalendar using a custom renderer. The renderer can be created like this:

    public class CustomizedCalendarRenderer:CalendarRenderer
    {
        protected override void OnElementChanged(Xamarin.Forms.Platform.WinPhone.ElementChangedEventArgs<Telerik.XamarinForms.Input.RadCalendar> e)
        {
            base.OnElementChanged(e);
            this.Control.Template = //here goes your custom template
        }
    } 
    In order to force the XamarinForms to use your custom renderer to visualize the RadCalendar component you will need to register your class like this:

    [assembly: Xamarin.Forms.ExportRenderer(typeof(Telerik.XamarinForms.Input.RadCalendar), typeof(X_Calendar.WinPhone.CustomizedCalendarRenderer))]
    Normally this is done in the MainPage.xaml.cs file.

    I hope this information sheds light on your case. Do not hesitate to contact us again if you need any further assistance.

    Regards,
    Pavel R. Pavlov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  5. Yordan
    Yordan avatar
    14 posts
    Member since:
    Jan 2013

    Posted 28 Dec 2015 in reply to Pavel R. Pavlov Link to this post

    Hi, Pavel,

    Yes, I was referring to wp 8.0.
    However, I don't understand how the link that you pointed me to will help me achieve my idea, since there is no property for setting the colors of the month row and the year row. Could you just give me a small example of it?

    Thanks in advance!

  6. Answer
    Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1183 posts

    Posted 29 Dec 2015 Link to this post

    Hi Dancho,

    You are right that there are no properties controlling the visualization of the parts you refer to. This is why I suggested customizing the ControlTemplate of the RadCalendar component. As Silverlight (XAML) developer you should be familiar with Blend and using it for customizing existing UI controls.
    In the referenced article there is a sentence saying:
    "To completely re-style the RadCalendar look and feel you can change its ControlTemplate as with any standard Silverlight control."
    This is what I was referring in my last post.

    In order to get familiar with the ControlTemplate you can refer to the Customizing the Appearance of an Existing Control by Using a ControlTemplate article of MSDN. At the very end of the article MS suggest two approaches for extracting the default ControlTemplate of existing component. You can follow the first one in order to get code you need to achieve your requirement.

    Also I found this blog post which summarizes everything you need to extract an existing ControlTemplate out of a component. 

    Once you have extracted it you will need to make the changes you require and then you will need to use that customized template in the earlier provided code. I believe the provided posts are far better than giving you the solution. The articles will help you build the needed knowledge and following them will give you experience based on which you will easily accomplish such tasks in the future.

    Regards,
    Pavel R. Pavlov
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner