XamForms.Controls.Calendar
XamForms.Controls.Calendar copied to clipboard
Cannot set Calendar startdate
I have tried setting the calendar startday both in XAML and also in code behind.
I have even tried placing it in 3 different areas:
in XAML that didn't work:
<controls:Calendar StartDate="{Binding Date}" EnableTitleMonthYearView="true" x:Name="calendar" Padding="10,0,10,0" StartDay="Monday" SelectedBorderWidth="4" DisabledBorderColor="Black">
</controls:Calendar>
So I tried adding it from c# code:
calendar = new XamForms.Controls.Calendar
{
BorderColor = Color.Gray,
BorderWidth = 3,
BackgroundColor = Color.White,
StartDay = DayOfWeek.Monday,
StartDate = DateTime.Now.AddDays(1)
};
and even using the method and field:
calendar.StartDate = Date;
calendar.CalendarStartDate(Date);
None of them worked :-(
Am I missing something? I even tried redrawing it forcefully but still, it didn't start the calendar from my designated date. I read I might need to add something to my AssemblyInfo.cs:
[assembly:Xamarin.Forms.Platform.<Platform>.ExportRenderer(typeof(XamForms.Controls.CalendarButton),typeof(XamForms.Controls.<Platform>.CalendarButtonRenderer))]
But, when I type this bit:
[assembly:Xamarin.Forms.Platform.
it does not even include iOS and Droid let alone ExportRenderer
What am I doing wrong here?
I used this and it works fine calendar.SelectedDate = DateTime.Today;
you can also do
MinDate="{Binding MinDate}" MaxDate="{Binding MaxDate}" in Xamal or code behind.
This option is nice if you want to limit the scrolling to the available dates from min to max and not scroll on disabled dates calendar.DisableDatesLimitToMaxMinRange = true;
@amirvenus please update us on this issue and close it if done
@amirvenus please update us on this issue and close it if done
thnx ali-h2010 itz working fine,
calendar.StartDate=DateTime.Today;