Hello,
How to Remove the Gray Line Between FlyoutItem and ShellContent in .NET MAUI Shell
If you set the FlyoutDisplayOptions="AsSingleItem"
, this gray line will disappear.
However, Only "Home" item will appear in the FlyoutItem. If you want to keep the AsMultipleItems and remove this grey line,
Please do not use ShellContent as your sign out function like following code. When you click the sign out item. You will get System.InvalidOperationException: 'No Content found for ShellContent, Title:, Route D_FAULT_ShellContent15'
<ShellContent Title="Sign Out" Icon="{OnPlatform 'settings.png'}" />
Based on your code, sign out function do not have a ContentPage.
You can move sign out function in the Shell.FlyoutFooter
or Shell.FlyoutHeader
. I move it to the Shell.FlyoutHeader
and use a Button to implement it.
<Shell.FlyoutHeader>
<StackLayout>
<Grid BackgroundColor="#00AFB9" Padding="20">
....
</Grid>
<Button Text="logout" Clicked="Button_Clicked"></Button>
</StackLayout>
</Shell.FlyoutHeader>
You can handle the sign out operation in the shell background code.
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
private void Button_Clicked(object sender, EventArgs e)
{
//close the flyout page and handle your logout operation.
Shell.Current.FlyoutIsPresented = false;
}
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.