XamForms.Controls.Calendar
XamForms.Controls.Calendar copied to clipboard
Paterns on special dates and special date Selection
Hello, great control. I have an scenario on which there is only one month, but I need patterns on my special dates. When selecting a special date that has a list of patterns as BackgroundPattern, some times said selected special date turns its background to white, loosing the pattern. I wasn't capable of pin pointing the exact ocurrance, It's a bit random. How can I fix it?
Hello.
I've noticed the same behaviour (only tested on Android).
It looks like the selected date background color overrides the backgroundPattern.
I've tried setting the SelectedBackgroundColor to Default or Transparent but it still overrides the backgroundPattern of the selected date.
By looking the code a bit it looks like (i think) the BackgroundPattern is being overridden by the default background color when a user selects a date. https://github.com/rebeccaXam/XamForms.Controls.Calendar/blob/9dacada447d08be6ced34041f6e5570ff33a95eb/XamForms.Controls.Calendar/Calendar.Selected.cs#L242
Hello.
I have the same problem.
Any solution?
I fixed it moving the assignment of BackgroundPattern at the end.
protected void SetButtonSelected(CalendarButton button, SpecialDate special) {
Device.BeginInvokeOnMainThread(() => {
button.BackgroundImage = special != null ? special.BackgroundImage : null;
var defaultBackgroundColor = button.IsOutOfMonth ? DatesBackgroundColorOutsideMonth : DatesBackgroundColor;
var defaultTextColor = button.IsOutOfMonth ? DatesTextColorOutsideMonth : DatesTextColor;
var defaultFontAttributes = button.IsOutOfMonth ? DatesFontAttributesOutsideMonth : DatesFontAttributes;
var defaultFontFamily = button.IsOutOfMonth ? DatesFontFamilyOutsideMonth : DatesFontFamily;
button.IsEnabled = true;
button.IsSelected = true;
button.FontSize = SelectedFontSize;
button.BorderWidth = SelectedBorderWidth;
button.BorderColor = SelectedBorderColor;
button.BackgroundColor = SelectedBackgroundColor != Color.Default ? SelectedBackgroundColor : (special != null && special.BackgroundColor.HasValue ? special.BackgroundColor.Value : defaultBackgroundColor);
button.TextColor = SelectedTextColor != Color.Default ? SelectedTextColor : (special != null && special.TextColor.HasValue ? special.TextColor.Value : defaultTextColor);
button.FontAttributes = SelectedFontAttributes != FontAttributes.None ? SelectedFontAttributes : (special != null && special.FontAttributes.HasValue ? special.FontAttributes.Value : defaultFontAttributes);
button.FontFamily = !string.IsNullOrEmpty(SelectedFontFamily) ? SelectedFontFamily : (special != null && !string.IsNullOrEmpty(special.FontFamily) ? special.FontFamily : defaultFontFamily);
button.BackgroundPattern = special != null ? special.BackgroundPattern : null;
});
}
@KerosenoDev can you make a pull request to this repository so we can get it fixed?