--- /dev/null
+using Xamarin.Forms;
+using Xamarin.Forms.Platform.Tizen;
+using TForms = Xamarin.Forms.Platform.Tizen.Forms;
+using ECalendar = ElmSharp.Calendar;
+using Tizen.Xamarin.Forms.Extension;
+using Tizen.Xamarin.Forms.Extension.Renderer;
+
+[assembly: ExportRenderer(typeof(CalendarView), typeof(CalendarViewRenderer))]
+
+namespace Tizen.Xamarin.Forms.Extension.Renderer
+{
+ public class CalendarViewRenderer : ViewRenderer<CalendarView, ECalendar>
+ {
+ public CalendarViewRenderer()
+ {
+ RegisterPropertyHandler(CalendarView.MinimumDateProperty, UpdateMinimumDate);
+ RegisterPropertyHandler(CalendarView.MaximumDateProperty, UpdateMaximumDate);
+ RegisterPropertyHandler(CalendarView.FirstDayOfWeekProperty, UpdateFirstDayOfWeek);
+ RegisterPropertyHandler(CalendarView.WeekDayNamesProperty, UpdateWeekDayNames);
+ RegisterPropertyHandler(CalendarView.SelectedDateProperty, UpdateSelectedDate);
+ }
+
+ protected override void OnElementChanged(ElementChangedEventArgs<CalendarView> e)
+ {
+ if (Control == null)
+ {
+ var calrendarView = new ECalendar(TForms.Context.MainWindow);
+ SetNativeControl(calrendarView);
+ }
+
+ if (e.OldElement != null)
+ {
+ Control.DateChanged -= DateChangedHandler;
+ }
+
+ if (e.NewElement != null)
+ {
+ Control.DateChanged += DateChangedHandler;
+ }
+
+ base.OnElementChanged(e);
+ }
+
+ void DateChangedHandler(object sender, ElmSharp.DateChangedEventArgs e)
+ {
+ ((IElementController)Element).SetValueFromRenderer(CalendarView.SelectedDateProperty, e.NewDate);
+ }
+
+ void UpdateMinimumDate()
+ {
+ Control.MinimumYear = Element.MinimumDate.Year;
+ }
+
+ void UpdateMaximumDate()
+ {
+ Control.MaximumYear = Element.MaximumDate.Year;
+ }
+
+ void UpdateFirstDayOfWeek()
+ {
+ Control.FirstDayOfWeek = Element.FirstDayOfWeek;
+ }
+
+ void UpdateWeekDayNames()
+ {
+ Control.WeekDayNames = Element.WeekDayNames;
+ }
+
+ void UpdateSelectedDate()
+ {
+ Control.SelectedDate = Element.SelectedDate;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using Xamarin.Forms;
+
+namespace Tizen.Xamarin.Forms.Extension
+{
+ /// <summary>
+ /// This is a calendar widget. It helps applications to flexibly display a calendar with day of the week, date, year and month.
+ /// </summary>
+ /// <example>
+ /// <code>
+ /// new CalendarView
+ /// {
+ /// FirstDayOfWeek = DayOfWeek.Monday,
+ /// MinimumDate = DateTime.MinValue,
+ /// MaximumDate = DateTime.MaxValue
+ /// }
+ /// </code>
+ /// </example>
+ public class CalendarView : View
+ {
+ public static readonly BindableProperty MinimumDateProperty = BindableProperty.Create(nameof(MinimumDate), typeof(DateTime), typeof(CalendarView), DateTime.MinValue);
+
+ public static readonly BindableProperty MaximumDateProperty = BindableProperty.Create(nameof(MaximumDate), typeof(DateTime), typeof(CalendarView), DateTime.MaxValue);
+
+ public static readonly BindableProperty FirstDayOfWeekProperty = BindableProperty.Create(nameof(FirstDayOfWeek), typeof(DayOfWeek), typeof(CalendarView), DayOfWeek.Sunday);
+
+ public static readonly BindableProperty WeekDayNamesProperty = BindableProperty.Create(nameof(WeekDayNames), typeof(IReadOnlyList<string>), typeof(CalendarView), new List<string> { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }, validateValue: (bindable, value) =>
+ {
+ List<string> weekDayNames = (List<string>)value;
+ int count = weekDayNames.Count;
+
+ return (count == 7);
+ });
+
+ public static readonly BindableProperty SelectedDateProperty = BindableProperty.Create(nameof(SelectedDate), typeof(DateTime), typeof(CalendarView), DateTime.Today, defaultBindingMode: BindingMode.TwoWay, propertyChanged: (bindable, oldValue, newValue) =>
+ {
+ ((CalendarView)bindable).SelectedDateChanged?.Invoke(bindable, new DateChangedEventArgs((DateTime)oldValue, (DateTime)newValue));
+ });
+
+ public event EventHandler<DateChangedEventArgs> SelectedDateChanged;
+
+ /// <summary>
+ /// Gets or sets the MinimumDate value.
+ /// Can use only Year.
+ /// </summary>
+ public DateTime MinimumDate
+ {
+ get { return (DateTime)GetValue(MinimumDateProperty); }
+ set { SetValue(MinimumDateProperty, value); }
+ }
+
+ /// <summary>
+ /// Gets or sets the MaximumDate value.
+ /// Can use only Year.
+ /// </summary>
+ public DateTime MaximumDate
+ {
+ get { return (DateTime)GetValue(MaximumDateProperty); }
+ set { SetValue(MaximumDateProperty, value); }
+ }
+
+ /// <summary>
+ /// Gets or sets the first day of week.
+ /// </summary>
+ public DayOfWeek FirstDayOfWeek
+ {
+ get { return (DayOfWeek)GetValue(FirstDayOfWeekProperty); }
+ set { SetValue(FirstDayOfWeekProperty, value); }
+ }
+
+ /// <summary>
+ /// Gets or sets the weekday names displayed by the calendar.
+ /// The number of items in WeekdayNames must be 7.
+ /// </summary>
+ public IReadOnlyList<string> WeekDayNames
+ {
+ get { return (IReadOnlyList<string>)GetValue(WeekDayNamesProperty); }
+ set { SetValue(WeekDayNamesProperty, value); }
+ }
+
+ /// <summary>
+ /// Gets or sets the selected date.
+ /// </summary>
+ public DateTime SelectedDate
+ {
+ get { return (DateTime)GetValue(SelectedDateProperty); }
+ set { SetValue(SelectedDateProperty, value); }
+ }
+ }
+}
\ No newline at end of file