How to create picker with search ? .NET MAUI framework

zc 51 Reputation points
2022-09-07T04:59:13.71+00:00

I can't find how create custom picker with search on .NET MAUI. Where can I find resources about it ?

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,594 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 44,011 Reputation points Microsoft Vendor
    2022-09-15T07:51:08.657+00:00

    Hello,

    As a matter of fact, picker is combined by a read-only entry and a pop-up page, therefore, you could implement it by Popup.

    Please refer to the following documentations:

    The following code code snippets could be helpful for you:

    Entry:

       <Entry IsReadOnly="True" >   
           <Entry.GestureRecognizers>  
               <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped"/> // Open your Popup Page in TapGestureRecognizer_Tapped method.  
           </Entry.GestureRecognizers>  
       </Entry>  
    

    Layout of Popup Page:

       <StackLayout VerticalOptions="Center"  Padding="10" HorizontalOptions="FillAndExpand" Margin="0,20,0,0" >   
           <StackLayout>  
               <SearchBar  x:Name="Searchbar">  
               </SearchBar>  
           </StackLayout>  
           <StackLayout>  
               <ListView  x:Name="ListView"  ItemsSource="{Binding Names}">  
                   <ListView.ItemTemplate>  
                       <DataTemplate>  
                           <ViewCell>  
                               <Label Text="{Binding .}"/>  
                           </ViewCell>  
                       </DataTemplate>  
                   </ListView.ItemTemplate>  
               </ListView>  
           </StackLayout>  
       </StackLayout>  
    

    Best Regards,

    Alec Liu.


    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.

    2 people found this answer helpful.

  2. dg2k 1,396 Reputation points
    2022-09-07T12:52:01.553+00:00

    @zc - I think you will find good guidance on Maui SearchBar here.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.