Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

not able to add a new property in XamForms.Controls.Calendar

$
0
0

Hello,

I am using calendar from https://github.com/rebeccaXam/XamForms.Controls.Calendar

I want to display circle in background when user selects a date. For that I created custom calendar and added BindableProperty for border radius.

Like this,

`using System.Collections.Generic;
using Xamarin.Forms;
using XamForms.Controls;

public class CustomCalendar : Calendar
{

    List<CalendarButton> buttons;

    public CustomCalendar()
    {
        buttons = new List<CalendarButton>();
    }

    /// <summary>
    /// Gets or sets the border radius of the selected date.
    /// </summary>
    /// <value>The width of the border.</value>

    public static readonly BindableProperty BorderRadiusProperty =
    BindableProperty.Create("BorderRadius", typeof(int), typeof(Calendar), 20,
    propertyChanged: (bindable, oldValue, newValue) => (bindable as CustomCalendar).ChangeBorderRadius((int)newValue, (int)oldValue));

    public int BorderRadius
    {
        get { return (int)GetValue(BorderRadiusProperty); }
        set { SetValue(BorderRadiusProperty, value); }
    }
    void ChangeBorderRadius(int newValue, int oldValue)
    {
        if (newValue == oldValue) return;

        if (newValue > 0) buttons.FindAll(b => b.IsSelected).ForEach(b => b.BorderRadius = newValue);

    }
}`

And using this CustomCalendar instead of calendar given by XamForms.Controls

in my calendar page code behind,

calendarNotification = new CustomCalendar
   {
     StartDay = DayOfWeek.Monday,
      SelectedBorderWidth = 4,
      VerticalOptions = LayoutOptions.FillAndExpand,
       HorizontalOptions = LayoutOptions.FillAndExpand
     };
     gridCalendar.Children.Add(calendarNotification);

but it gives me error when I reach to bindable property syntax while debugging.

The error is

{Xamarin.Forms.Xaml.XamlParseException: Position 9:10. Type controls:CalendarButton not found in xmlns clr-namespace:XamForms.Controls
  at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, INode parentNode) [0x0005a] in ......

If I don't use CalendarButton then also I get this error. I also made custom calendar button and tried using it but error still exists.

Thanks.


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>