Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set Calendar startdate #70

Open
amirvenus opened this issue Feb 24, 2018 · 5 comments
Open

Cannot set Calendar startdate #70

amirvenus opened this issue Feb 24, 2018 · 5 comments

Comments

@amirvenus
Copy link

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?

@ali-h2010
Copy link

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

@ali-h2010
Copy link

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
Copy link

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

1 similar comment
@ali-h2010
Copy link

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

@Muthutc
Copy link

Muthutc commented Jul 16, 2018

thnx ali-h2010
itz working fine,

calendar.StartDate=DateTime.Today;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants