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.
4 Answers, 1 is accepted
But still my question stands - is there a way to change the color of the month and year only?
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:
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:
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.
Pavel R. Pavlov
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!
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.
Pavel R. Pavlov