How to close Calendar in full screen mode on Android

Posted by: pmatushkin on 27 October 2017, 4:28 am EST

    • Post Options:
    • Link

    Posted 27 October 2017, 4:28 am EST

    What is the intended way of closing fullscreen Calendar on Android?

    I’m playing with the dropdown sample in C1Input101 demo project. When I add DropDownMode=“FullScreen” to C1DropDown defintion, like so, it seems impossible to close calendar without selecting a date:

    <Grid>
        <c1:C1DropDown x:Name="dropdown" HorizontalOptions="FillAndExpand" VerticalOptions="Start" DropDownMode="FullScreen">
            <c1:C1DropDown.Header>
                <c1:C1MaskedEntry x:Name="mask" Mask="00/00/0000"/>
            </c1:C1DropDown.Header>
            <c1:C1DropDown.DropDown>
                <calendar:C1Calendar x:Name="calendar" HorizontalOptions="FillAndExpand" DayOfWeekFormat="d"  BackgroundColor="Transparent" WidthRequest="270" HeightRequest="270" />
            </c1:C1DropDown.DropDown>
        </c1:C1DropDown>
    </Grid>
    
    

    The natural way of dismissing a fullscreen view on Android would be pressing Back button, but in this case pressing Back button closes the calendar AND the underlying activity. Selecting a date dismisses the calendar, but I want to be able to dismiss it without making a selection.

  • Posted 31 October 2017, 3:41 pm EST

    To dismiss the DropDown without selecting a date from the Calendar and not close the app on pressing the back button, please override the OnBackButtonPressed method in your xaml page as below:

    protected override bool OnBackButtonPressed()
            {
                if (Device.OS == TargetPlatform.Android && dropdown.IsDropDownOpen)
                {
                    dropdown.IsDropDownOpen = false;
                    return true;
                }            
                else
                    return base.OnBackButtonPressed();
            }
    
  • Posted 1 November 2017, 5:19 am EST

    Thank you.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels