XamForms.Controls.Calendar icon indicating copy to clipboard operation
XamForms.Controls.Calendar copied to clipboard

Cannot set Calendar startdate

Open amirvenus opened this issue 7 years ago • 5 comments

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?

amirvenus avatar Feb 24 '18 21:02 amirvenus

I used this and it works fine calendar.SelectedDate = DateTime.Today;

ali-h2010 avatar Feb 28 '18 11:02 ali-h2010

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;

ali-h2010 avatar Feb 28 '18 11:02 ali-h2010

@amirvenus please update us on this issue and close it if done

ali-h2010 avatar Mar 07 '18 10:03 ali-h2010

@amirvenus please update us on this issue and close it if done

ali-h2010 avatar Apr 17 '18 07:04 ali-h2010

thnx ali-h2010 itz working fine,

calendar.StartDate=DateTime.Today;

Muthutc avatar Jul 16 '18 10:07 Muthutc