lubiepomaranczki / xamforms.controls.calendar Goto Github PK
View Code? Open in Web Editor NEWCustom calendar control for Xamarin.Forms.
License: MIT License
Custom calendar control for Xamarin.Forms.
License: MIT License
The app freezes after starting Calender View several times...
in View XAML:
DateCommand="{Binding DateChosenCommand}"
in ViewModel:
private void DateChosen(object obj) { System.Diagnostics.Debug.WriteLine("Selected: " + Date.ToString()); }
output:
Endless output
Selected: 12.10.2021 10:27:01
Selected: 12.10.2021 10:27:01
Selected: 12.10.2021 10:27:01
Selected: 12.10.2021 10:27:01
Selected: 12.10.2021 10:27:02
Selected: 12.10.2021 10:27:02
Selected: 12.10.2021 10:27:02
Selected: 12.10.2021 10:27:02
Selected: 12.10.2021 10:27:02
....
When you add ArrowImages to the control and you don't remove ArrowText two back arrows are visible. Not cool.
<supercalendar:Calendar
TitleLeftArrowImage="back_icon"
TitleRightArrowImage="forward_icon">
When TitleLeftArrowImage
or TitleRightArrowImage
is set we should hide TitleLeftArrowText
& TitleRightArrowText
.
Spotted in #36
Despite the fact that Rebecca did a great job, the code is pretty slow and messy. I would really appreciate if you can help me and clean it up
Currently old readme.md
is being used. Please update it so it is up to date
I need to get a set of Dates using this control and have thus set MultiSelectDates="True"
. However, the property SelectedDates
doesn't appear on the IntelliSense when typed on the XAML Editor and neither does the object bounded to it (SelectedDates="{Binding SelectedDateCollection}"
) triggers updates when Dates are being selected from the control.
Hello,
Hopefully, someone will help me with the problem that I have.
In CalendarPage.xaml.cs I'm getting credentials through the constructor and passing them to the instance of view model: Calendar.cs ->
public CalendarPage(string _username, string _password, int _currentDoctorId)
{
InitializeComponent();
Calendar = new Calendar();
Calendar._username = _username;
Calendar._password = _password;
Calendar._currentDoctorId = _currentDoctorId;
Calendar._detectAppointments.Execute(null);
BindingContext = Calendar;
}
The thing is that I want to load the SpecialDates (in my case appointments from the database) at startup.
So, I am triggering the _detectAppointments Command ->
public async Task DetectAppointments()
{
//IsBusy = true;
APIservice.Username = _username;
APIservice.Password = _password;
SearchAppointmentRequest request = new SearchAppointmentRequest();
request._docId = _currentDoctorId;
List<Appointment> _detect = await _appointmentService.Get<List<Appointment>>(request);
SpecialDates.Clear();
foreach(Appointment a in _detect)
{
AddSpecialDate(a.Date);
}
}
...and adding the special date to the binded ObservableCollection ->
private void AddSpecialDate(DateTime date)
{
SpecialDate spec = new SpecialDate(date)
{
Selectable = true,
BackgroundPattern = new BackgroundPattern(1)
{
Pattern = new List
{
new Pattern { WidthPercent = 1f, HightPercent = 0.6f, Color = Color.Transparent },
new Pattern{ WidthPercent = 1f, HightPercent = 0.4f, Color = Color.Transparent, Text = "Appointments", TextColor=Color.Black, TextSize=10, TextAlign=TextAlign.Middle}
}
}
};
SpecialDates.Add(spec);
}
The problem is when the page loads SpecialDates are not marked on the calendar. Not until I press the arrow for the past or next month...
So, I am wondering is there a possibilitie to force redraw from the view model? Or to refresh the calendar? And I am not shure why it is not refreshing the since the data binding is set, too. ->
private ObservableCollection _specialDates { get; set; } = new ObservableCollection();
public ObservableCollection SpecialDates
{
get
{
return _specialDates;
}
set
{
_specialDates = value;
OnPropertyChanged(nameof(SpecialDates));
}
}
Thanks in advance.
I would really appreciate some help.
Hello there,
I'm sorry, I've looked at open issues, but I can't find a solution to my problem.
What I want to do; Importing the dates in the firebase database to SpecialDates. I successfully retrieve data from Firebase, but I cannot import it to the calendar. I tried this with the following method, but I didn't succeed. I would be glad if you help. Thanks in advance ...
Xaml source
<controls:Calendar
Padding="10,0,10,0"
SelectedBorderWidth="4"
DisabledBorderColor="Black"
ShowNumberOfWeek="false"
StartDay="Monday"
TitleLabelTextColor="Purple"
DateClicked="Calendar_DateClicked"
x:Name="calender"
BindingContext="{Binding Tarih}"
WeekdaysShow="True"
WeekdaysFontAttributes="Bold"
EnableTitleMonthYearView="True"
TitleLeftArrowTextColor="Blue"
SelectedDate="{Binding Date}"
SpecialDates="{Binding Tarih}"
DateCommand="{Binding DateChosen}" >
</controls:Calendar>
Code behind:
public Detail()
{
InitializeComponent();
DBFire data;
data = new DBFire();
Device.BeginInvokeOnMainThread(async () =>
{
calender.BindingContext = await data.GetList();
});
}
Hello,
Hopefully, someone will help me with the problem that I have.
In CalendarPage.xaml.cs I'm getting credentials through the constructor and passing them to the instance of view model:
Calendar.cs ->
public CalendarPage(string _username, string _password, int _currentDoctorId)
{
InitializeComponent();
Calendar = new Calendar();
Calendar._username = _username;
Calendar._password = _password;
Calendar._currentDoctorId = _currentDoctorId;
Calendar._detectAppointments.Execute(null);
BindingContext = Calendar;
}
The thing is that I want to load the SpecialDates (in my case appointments from the database) at startup.
So, I am triggering the _detectAppointments Command ->
public async Task DetectAppointments()
{
//IsBusy = true;
APIservice.Username = _username;
APIservice.Password = _password;
SearchAppointmentRequest request = new SearchAppointmentRequest();
request._docId = _currentDoctorId;
List<Appointment> _detect = await _appointmentService.Get<List<Appointment>>(request);
SpecialDates.Clear();
foreach(Appointment a in _detect)
{
AddSpecialDate(a.Date);
}
}
and adding the special date to the binded ObservableCollection ->
private void AddSpecialDate(DateTime date)
{
SpecialDate spec = new SpecialDate(date)
{
Selectable = true,
BackgroundPattern = new BackgroundPattern(1)
{
Pattern = new List<Pattern>
{
new Pattern { WidthPercent = 1f, HightPercent = 0.6f, Color = Color.Transparent },
new Pattern{ WidthPercent = 1f, HightPercent = 0.4f, Color = Color.Transparent, Text = "Appointments", TextColor=Color.Black, TextSize=10, TextAlign=TextAlign.Middle}
}
}
};
SpecialDates.Add(spec);
}
The problem is when the page loads SpecialDates are not marked on the calendar. Not until I press the arrow for the past or next month...
So, I am wondering is there a possibility to force redraw from the view model? Or to refresh the calendar? And I am not shure why it is not refreshing since the data binding is set, too. ->
private ObservableCollection<SpecialDate> _specialDates { get; set; } = new ObservableCollection<SpecialDate>();
public ObservableCollection<SpecialDate> SpecialDates
{
get
{
return _specialDates;
}
set
{
_specialDates = value;
OnPropertyChanged(nameof(SpecialDates));
}
}
Thanks in advance.
I would really appreciate some help.
Hello. First of all, I would like to say thank you for maintaining this library. This is my first Xamarin project and I happen to use this library.
So, I found out that every time I clicked the CalendarButton on a MultiSelectDates mode calendar, the content of SelectedDates would double by the same value (ex: I click on 23 March 2020, then there would be two 23 March 2020s inside SelectedDates). Does it really how it should be?
Thank you.
Hi,
When selecting a date in the calendar and unselecting it, as you can see on the photo, some space is created around the square of the date which kinda make the calendar look weird since the space between all dates isn't uniform anymore. Same thing happens in my app if i change the background color of the colored date to normal.
I don't know if it's something fixable but i'm just letting you know !
Thanks for the plugin :)
On the CalendarDemo project, try setting a specific date (either through the view model or directly to the calendar). When the calendar is displayed it still shows the current date selected even though I'm sending a different date.
_vm = new CalendarVM(); _vm.Date = DateTime.Now.AddDays(10); var c2 = new CalendarXamlView(); c2.BindingContext = _vm;
When I add the project from nuget, all the xaml files complain (even if they don't reference it...) that it is unable to resolve the assembly "XamForms.Controls.Calendar"
When I check the nuget packages folder, the .netstandard library does not have that dll (just XamForms.Enhanced.dll)
I saw that if you have MultiSelectedDates to true, you can use SelectedDates to unselect so i could do calendar.SelectedDates.Clear() and it would work but my problem is that i don't have SelectedDates set to true.
Here i have MultiSelectedDates to false, and even if i set SelectedDate to null, the Date still has a selected border and is still selected. Is there a way with your plugin to clear the selected date?
I need it for my app, because when the Calendar page is loaded, it always keeps the Date u selected before selected, which i don't want ?
Is there a way to do that ? Thanks a lot !
Hey,
Android has AutomationID. For example 10 January: NoResourceEntry-750 or NoResourceEntry-895 etc.
"NoResourceEntry-" part is constant. It chages only second part. And I use this in my uitests. But iOS has not any automation id.
Could you add automation id for ios, please?
Setting HideSpecialOutOfMonth
to true along with DatesBackgroundColorOutsideMonth="White"
and DatesTextColorOutsideMonth="White"
hides the dates outside month when using special dates.
<controls:Calendar Padding="5,0,5,0" DatesFontSize="16" WeekdaysFontSize="16" ShowNumberOfWeek="false" DatesBackgroundColorOutsideMonth="White" DatesTextColorOutsideMonth="White" StartDay="Monday" BackgroundColor="White" TitleLabelTextColor="#000000" TitleLeftArrowTextColor="#007AFF" TitleRightArrowTextColor="#007AFF" TitleRightArrowText=">" TitleLeftArrowText="<" SelectedDate="{Binding SelectedDate}" SpecialDates="{Binding AvailableDates}" DateCommand="{Binding DateChosenCommand}" BorderWidth="0" BorderColor="White" DisabledBackgroundColor="White" DisabledBorderColor="White" DisabledBorderWidth="0" DisabledTextColor="#949494" OuterBorderWidth="0" SelectedBorderWidth="0" >
Have set BorderWidth = 0
and BorderColor = Color.Transparent
for Special dates. So they look fine, but only the dates outside month has border lines (Only in Android).
In Android I see border lines like below.
Where as iOS is very clean.
I was wondering if there is any option like DatesBorderColorOutsideMonth
or DatesBorderWidthOutsideMonth
, to get rid of those borders for dates outside month
The control seems to have an issue this year (leap year?). This is my code:
XamForms.Controls.Calendar cal = new XamForms.Controls.Calendar
{
BorderWidth = options.BorderWidth,
BorderColor = System.Drawing.Color.DarkGray,
WeekdaysTextColor = System.Drawing.Color.White,
WeekdaysBackgroundColor = System.Drawing.Color.Brown,
TitleLabelTextColor = System.Drawing.Color.DarkGreen,
SelectedBorderColor = System.Drawing.Color.Yellow,
SelectedBackgroundColor = System.Drawing.Color.DodgerBlue,
SelectedTextColor = System.Drawing.Color.White,
BackgroundColor = options.BackgroundColour,
StartDay = DayOfWeek.Monday,
StartDate = DateTime.Now.AddMonths(-1),
ShowNumOfMonths = 2,
ShowInBetweenMonthLabels = true,
WidthRequest = common.Width / 3,
HeightRequest = common.Width / 3,
SelectedDate = DateTime.Now,
};
Here is the output for Feb and Mar that looks ok:
But if I go back then Dec and Jan are wrong (1st Jan was Wednesday etc)
Assuming I have SpecialDate like this:
new SpecialDate(DateTime.Now.AddDays(4))
{
Selectable = true,
BackgroundPattern = new BackgroundPattern(1)
{
Pattern = new List<Pattern>
{
new Pattern{ WidthPercent = 1f, HightPercent = 0.5f, Color = Color.Red},
new Pattern{ WidthPercent = 1f, HightPercent = 0.5f, Color = Color.Purple},
}
},
BackgroundImage = ImageSource.FromFile("ic_calendarCircle.png") as FileImageSource
}
ic_calendarCircle is an image with alfa as background, hence the pattern should be visible.
The problem is that the image is not visible at all.
I am having trouble because whenever you select a date and try to unselect it by clicking on the same date ( which should technically mean that the date is unselected because there's no red square around it anymore).
I don't know how i can check that the date has been unselected because it still keep the data of dateChosen even if the redsquare isn't there anymore ( only when clicking on the same date).
This doesn't happen if i click a different date or empty date, i just want to fix this behaviour when clicking a same date because as you can see on the screenshots, it's kinda weird.
In my function, i have an else statement to deal with empty date to hide everything and it works, but this code should in my opinion be executed when you unselect by clicking the same date, no ? But it doesn't since it keeps dateChosen data.
NOTE: dateChosen will become empty when the whole function is done executing so there's no way for me to deal with it inside my function.
So is it normal that when you click on a date to select it and then click on the same date again to unselect it, the dateChosen still has date and is there a way i can fix this ? Thanks.
Thank you.
function:
` public ICommand DateChosen => new Command((obj) =>
{
var dateChosen = obj as DateTime?;
if (dateChosen != null)
{
tasksGroup = App.Database.GetTaskGroupByDate(dateChosen.Value).GetAwaiter().GetResult();
if (tasksGroup != null)
{
var data = App.Database.GetTaskByGroupId(TasksGroup.ID).GetAwaiter().GetResult();
TasksGroup = tasksGroup;
TasksGroup.Taches = data;
TasksGroup.ExpositionResult = Helper.CalculateExposition(TasksGroup);
ExpositionResult = TasksGroup.ExpositionResult;
Tasks = new ObservableCollection<Tasks>(data);
TasksGroup.Taches.ForEach(x =>
{
TaskDBA = x.TaskDBA;
TaskDuration = x.TaskDuration;
TaskDescription = x.TaskDescription;
TaskComment = x.TaskComment;
});
TasksGroupExistBool = false;
PancakeViewBool = true;
ResultatLabel = "Resultat: ";
DbaLabel = " dBA";
if(!dateChosen.HasValue)
{
Date = TasksGroup.TasksGroupDate;
}
}
else
{
DbaLabel = "";
ResultatLabel = "";
TasksGroupExistBool = true;
PancakeViewBool = false;
Tasks = null;
TasksGroup = null;
ExpositionResult = null;
ExpanderBool = false;
}
}
NotifyPropertyChanged();
});`
Selection:
Clicking on the same date again (the 28th case) :
Hi,
I trying to change titleLeftArrow and titleRightArrow:
TitleLeftArrowImage="left.png"
TitleRightArrowImage="right.png"
New images show up, but old (red arrows) are still visible.
How replace default arrows?
I am showing the page as Pop up, I am using Rg.Plugins.Popup
When pop up try to close pop up:
{System.NullReferenceException: Object reference not set to an instance of an object
at XamForms.Controls.iOS.CalendarButtonRenderer.OnElementPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) [0x0004a] in :0
at (wrapper delegate-invoke) .invoke_void_object_PropertyChangedEventArgs(object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:229
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Element.cs:353
at Xamarin.Forms.BindableObject.ClearValue (Xamarin.Forms.BindableProperty property, System.Boolean fromStyle, System.Boolean checkAccess) [0x000c6] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:96
at Xamarin.Forms.BindableObject.ClearValue (Xamarin.Forms.BindableProperty property) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:48
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) [0x00077] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:373 at Xamarin.Forms.Platform.iOS.ViewRenderer
2[TView,TNativeView].Dispose (System.Boolean disposing) [0x0005c] in D:\a\1\s\Xamarin.Forms.Platform.iOS\ViewRenderer.cs:124
at Xamarin.Forms.Platform.iOS.ButtonRenderer.Dispose (System.Boolean disposing) [0x00067] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Renderers\ButtonRenderer.cs:72
at Foundation.NSObject.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.1.31/src/Xamarin.iOS/Foundation/NSObject2.cs:147
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose (System.Boolean disposing) [0x0003f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:71
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:39
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) [0x00058] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:365 at Foundation.NSObject.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.1.31/src/Xamarin.iOS/Foundation/NSObject2.cs:147 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose (System.Boolean disposing) [0x0003f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:71 at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:39 at Xamarin.Forms.Platform.iOS.VisualElementRenderer
1[TElement].Dispose (System.Boolean disposing) [0x00058] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:365
at Foundation.NSObject.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.1.31/src/Xamarin.iOS/Foundation/NSObject2.cs:147
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose (System.Boolean disposing) [0x0003f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:71
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:39
at Xamarin.Forms.Platform.iOS.VisualElementRenderer`1[TElement].Dispose (System.Boolean disposing) [0x00058] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementRenderer.cs:365
at Foundation.NSObject.Dispose () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.1.31/src/Xamarin.iOS/Foundation/NSObject2.cs:147
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose (System.Boolean disposing) [0x0003f] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:71
at Xamarin.Forms.Platform.iOS.VisualElementPackager.Dispose () [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.iOS\VisualElementPackager.cs:39
โฆ
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.