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

Calendar ignores value of NavigationLowerBound #171

Open
ME-MarvinE opened this issue Jan 17, 2024 · 8 comments
Open

Calendar ignores value of NavigationLowerBound #171

ME-MarvinE opened this issue Jan 17, 2024 · 8 comments
Labels
awaiting-author Awaiting a respose from the author bug Something isn't working

Comments

@ME-MarvinE
Copy link
Owner

Original Issue:
ME-MarvinE/XCalendarGettingStarted#2

@ME-MarvinE
Copy link
Owner Author

ME-MarvinE commented Jan 18, 2024

I'm surprised it took this long for this to be uncovered, nice catch. A new version with the fix will be released in the next few hours.

@ME-MarvinE
Copy link
Owner Author

ME-MarvinE commented Jan 18, 2024

Should be fixed by #172 in version 4.5.4 of XCalendar.Core

@ME-MarvinE ME-MarvinE added the awaiting-author Awaiting a respose from the author label Jan 23, 2024
@ME-MarvinE ME-MarvinE reopened this Apr 3, 2024
@ME-MarvinE
Copy link
Owner Author

ME-MarvinE commented Apr 3, 2024

I see in your images and code that you've set the lower bound to "Today".

The default behavior of the calendar is to loop to the upper bound once you reach the lower bound, and since you haven't set an upper bound, it goes to DateTime.MaxValue and that's why it displays December 9999.

I don't know why all the dates are the same though, I'll look into that. What does your XAML look like?

@ME-MarvinE
Copy link
Owner Author

Setting the lower bound works fine in the "Getting Started" repo. The dates below the minimum turn red as they should.

@pjdavid
Copy link

pjdavid commented Apr 6, 2024

Here's my code. It works fine on previous versions as soon as I upgrade to the latest version I get the issue with the dates

<calendar:CalendarView
                x:Name="FancyCalendarView"
                LeftArrowCommand="{Binding NavigateCalendarCommand, Source={x:Reference this}}"
                Days="{Binding MyCalendar.Days, Source={x:Reference this}}"
                DaysOfWeek="{Binding MyCalendar.DayNamesOrder, Source={x:Reference this}}"
                RightArrowCommand="{Binding NavigateCalendarCommand, Source={x:Reference this}}"
                NavigatedDate="{Binding MyCalendar.NavigatedDate, Source={x:Reference this}}">
                <calendar:CalendarView.RightArrowCommandParameter>
                    <x:Int32>1</x:Int32>
                </calendar:CalendarView.RightArrowCommandParameter>
                <calendar:CalendarView.LeftArrowCommandParameter>
                    <x:Int32>-1</x:Int32>
                </calendar:CalendarView.LeftArrowCommandParameter>
                <calendar:CalendarView.NavigationViewTemplate>
                    <ControlTemplate>
                        <calendar:NavigationView
                            LeftArrowCommand="{Binding LeftArrowCommand, Source={x:RelativeSource TemplatedParent}}"
                            LeftArrowCommandParameter="{Binding LeftArrowCommandParameter, Source={RelativeSource TemplatedParent}}"
                            RightArrowCommand="{Binding RightArrowCommand, Source={x:RelativeSource TemplatedParent}}"
                            RightArrowCommandParameter="{Binding RightArrowCommandParameter, Source={RelativeSource TemplatedParent}}"
                            HeightRequest="40"
                            ArrowColor="DarkGray"
                            TextColor="Black"
                            Text="{Binding Text, Source={RelativeSource TemplatedParent}}"/>
                    </ControlTemplate>
                </calendar:CalendarView.NavigationViewTemplate>
                <calendar:CalendarView.DayTemplate>
                    <DataTemplate x:DataType="{x:Type xcInterfaces:ICalendarDay}">
                        <ContentView>
                            <Frame
                                Padding="0"
                                CornerRadius="0"
                                HasShadow="False">
                                <calendar:DayView
                                    DateTime="{Binding DateTime}"
                                    IsCurrentMonth="{Binding IsCurrentMonth}"
                                    IsInvalid="{Binding IsInvalid}"
                                    IsSelected="{Binding IsSelected}"
                                    IsToday="{Binding IsToday}">
                                    <calendar:DayView.InvalidStyle>
                                        <Style TargetType="{x:Type calendar:DayView}">
                                            <Setter Property="HeightRequest" Value="50" />
                                            <Setter Property="TextColor" Value="LightGray" />
                                        </Style>
                                    </calendar:DayView.InvalidStyle>
                                    <calendar:DayView.OtherMonthStyle>
                                        <Style TargetType="{x:Type calendar:DayView}">
                                            <Setter Property="HeightRequest" Value="50" />
                                            <Setter Property="TextColor" Value="Transparent" />
                                        </Style>
                                    </calendar:DayView.OtherMonthStyle>

                                    <calendar:DayView.CurrentMonthStyle>
                                        <Style TargetType="{x:Type calendar:DayView}">
                                            <Setter Property="Command" Value="{Binding ChangeDateSelectionCommand, Source={x:Reference this}}"/>
                                            <Setter Property="CommandParameter" Value="{Binding DateTime}"/>
                                            <Setter Property="HeightRequest" Value="50" />
                                            <Setter Property="TextColor" Value="Black" />
                                        </Style>
                                    </calendar:DayView.CurrentMonthStyle>

                                    <calendar:DayView.TodayStyle>
                                        <Style TargetType="{x:Type calendar:DayView}">
                                            <Setter Property="Command" Value="{Binding ChangeDateSelectionCommand, Source={x:Reference this}}"/>
                                            <Setter Property="CommandParameter" Value="{Binding DateTime}"/>
                                            <Setter Property="TextColor" Value="Black"/>
                                            <Setter Property="FontFamily" Value="Inter-Bold" />
                                        </Style>
                                    </calendar:DayView.TodayStyle>

                                    <calendar:DayView.SelectedStyle>
                                        <Style TargetType="{x:Type calendar:DayView}">
                                            <Setter Property="Command" Value="{Binding ChangeDateSelectionCommand, Source={x:Reference this}}"/>
                                            <Setter Property="CommandParameter" Value="{Binding DateTime}"/>
                                            <Setter Property="BackgroundColor" Value="#FC8300"/>
                                            <Setter Property="TextColor" Value="White"/>
                                            <Setter Property="HeightRequest" Value="50" />
                                        </Style>
                                    </calendar:DayView.SelectedStyle>

                                </calendar:DayView>
                            </Frame>
                        </ContentView>
                    </DataTemplate>
                </calendar:CalendarView.DayTemplate>
            </calendar:CalendarView>

@ME-MarvinE
Copy link
Owner Author

ME-MarvinE commented Apr 6, 2024

I replaced the code in the getting started app with yours. I renamed the namespace "xc" to "calendar" so it would match your XAML.

  • I got a compilation error that "ICalendarDay" could not be resolved; there is a change in 4.6.0 which makes the interface ICalendarDay require a type parameter, so using it in XAML is no longer an option.
    You can either create an interface which implements ICalendarDay with a specific type, or you can change DataTemplate x:DataType="{x:Type xcInterfaces:ICalendarDay}" to DataTemplate x:DataType="{x:Null}" (you won't get intellisense if you do this) which is what I did.

  • Next, I added x:Name="this" to the page since I got a runtime error saying the name "this" could not be resolved.

  • Then I got compilation errors saying "The property "NavigateCalendarCommand" was not found" and "The property "MyCalendar" was not found". So I replaced those occurrences to say BindingContext.NavigateCalendarComand and BindingContext.MyCalendar so it would reference the ViewModel of the page which is where those properties are located.

After that, I got this:
image

The dates seem to show fine - each day has the correct date. The invalid dates are grey, the current ones are black, and the other month ones are invisible. I wasn't able to replicate your issue with the same date repeating.

This was on XCalendar.Maui 4.6.0 running on Windows 10.

@ME-MarvinE
Copy link
Owner Author

ME-MarvinE commented Apr 12, 2024

@pjdavid Have you managed to get it working correctly by applying the 1st (and 3rd if you're using a ViewModel) changes I mentioned?

@pjdavid
Copy link

pjdavid commented Apr 12, 2024

I'm testing this implementation today. I had to downgrade for now but today I'm going to update again to try your suggestions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-author Awaiting a respose from the author bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants