docs-maui icon indicating copy to clipboard operation
docs-maui copied to clipboard

On window platform, SearchHandler causes tabbar to spawn, how to hide it?

Open wanghonghust opened this issue 1 year ago • 0 comments

The version of dotnet I am using is 8.0

1.The Shell code is as follows

<Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
       xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
       xmlns:controls="clr-namespace:Xaminals.Controls"
       xmlns:sys="clr-namespace:System;assembly=netstandard"
       xmlns:views="clr-namespace:Xaminals.Views"
       x:Class="Xaminals.AppShell"
       x:Name="shell"
       FlyoutBackgroundImage="photo.jpg"
       FlyoutBackgroundImageAspect="AspectFill" FlyoutBehavior="Locked">
    <Shell.FlyoutHeader>
        <controls:FlyoutHeader />
    </Shell.FlyoutHeader>
    <ShellContent Route="cats"
                          Title="Cats"
                          Icon="cat.png"
                          ContentTemplate="{DataTemplate views:CatsPage}" />
    <ShellContent Route="dogs"
                          Title="Dogs"
                          Icon="dog.png"
                          ContentTemplate="{DataTemplate views:DogsPage}" />
    <ShellContent Route="monkeys"
                      Title="Monkeys"
                      Icon="monkey.png"
                      ContentTemplate="{DataTemplate views:MonkeysPage}" />
    <ShellContent Route="elephants"
                      Title="Elephants"
                      Icon="elephant.png"
                      ContentTemplate="{DataTemplate views:ElephantsPage}" />
    <ShellContent Route="bears"
                      Title="Bears"
                      Icon="bear.png"
                      ContentTemplate="{DataTemplate views:BearsPage}" />
    <ShellContent Route="about"
                  Title="About"
                  Icon="info.png"
                  ContentTemplate="{DataTemplate views:AboutPage}" />
    <MenuItem Text="Help"
              IconImageSource="help.png"
              Command="{Binding HelpCommand}"
              CommandParameter="https://docs.microsoft.com/dotnet/maui/fundamentals/shell" />
    <Shell.FlyoutFooter>
        <controls:FlyoutFooter />
    </Shell.FlyoutFooter>
</Shell>```


2. Cats Page:


```xaml<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:controls="clr-namespace:Xaminals.Controls"
             xmlns:data="clr-namespace:Xaminals.Data"
             xmlns:views="clr-namespace:Xaminals.Views"
             x:Class="Xaminals.Views.CatsPage"
             Title="Cats">
    <ContentPage.Resources>
        <Style TargetType="Grid">
            <Setter Property="VisualStateManager.VisualStateGroups">
                <VisualStateGroupList>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal" />
                        <VisualState x:Name="Selected">
                            <VisualState.Setters>
                                <Setter Property="BackgroundColor" 
                                        Value="#039BE6" />
                            </VisualState.Setters>
                        </VisualState>
                    </VisualStateGroup>
                </VisualStateGroupList>
            </Setter>
        </Style>
    </ContentPage.Resources>
    <Shell.SearchHandler>
        <controls:AnimalSearchHandler Placeholder="Enter search term"
                                      ShowsResults="true"
                                      ItemTemplate="{StaticResource AnimalSearchTemplate}"
                                      Animals="{x:Static data:CatData.Cats}"
                                      SelectedItemNavigationTarget="{x:Type views:CatDetailPage}" />
    </Shell.SearchHandler>
    <CollectionView Margin="20"
                    ItemsSource="{x:Static data:CatData.Cats}"
                    ItemTemplate="{StaticResource AnimalTemplate}"
                    SelectionMode="Single"
                    SelectionChanged="OnCollectionViewSelectionChanged" />
</ContentPage>
  1. When SearchHandler is removed, the tab will not be shown, when it is added it will show the tab, how should I hide it?3. When SearchHandler is removed, the tab will not be shown, when it is added it will show the tab, how should I hide it?

Snipaste_2023-12-19_10-44-27

wanghonghust avatar Dec 19 '23 03:12 wanghonghust