c# – How do I dismiss the underside sheet from a button click on occasion inside the underside sheet?.internet MAUI


I used this management in my undertaking:
https://github.com/the49ltd/The49.Maui.BottomSheet

I’ve created a backside sheet on my homepage, it may be dismissed after I tapped outdoors the underside sheet, however it appears can’t be dismissed as soon as I click on a button inside the underside sheet.

That is my code to show the underside sheet:

non-public async void OnClicked(System.Object sender, System.EventArgs e)
        {
            strive
            {

                sheet.HasHandle = true;
                sheet.IsCancelable = true;
                
                await sheet.ShowAsync(Window);
            }
            catch (Exception ex)
            {
                await App.Present.MainPage.DisplayAlert("Error!", ex.Message, "OK!");
            }
        }

That is my xaml code:

<btm:BottomSheet xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="SampleProject.CustomViews.TicketListBottomSheet"
             xmlns:btm = "https://schemas.the49.com/dotnet/2023/maui"
             Padding="16,32"
             Background="{AppThemeBinding Mild={StaticResource White},Darkish={StaticResource Gray500}}"
             >
        <Grid Margin="0,2,0,5">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <Button Grid.Column="0" Textual content="Cancel" FontAttributes="Daring" FontFamily="Daring"  WidthRequest="150" TextColor="#1414A0" BackgroundColor="#E5E5FF" CornerRadius="20"  HorizontalOptions="FillAndExpand"
                    Clicked="Cancel_Clicked" />
            <Button Grid.Column="1" Textual content="Apply" FontAttributes="Daring"  FontFamily="Daring" WidthRequest="150" Model="{StaticResource PrimaryButtonStyle}" HorizontalOptions="FillAndExpand"
                    Clicked="Apply_Clicked"/>
        </Grid>
</btm:BottomSheet>

What I’m anticipating:
I need the underside sheet to have the ability to be self dismissed throughout the management itself as soon as I clicked the ‘Cancel’ button

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles