Is the .Net Maui Listview.Header tag able to contain a label with Text Search and SearchBar control

Ronald Rex 1,666 Reputation points
2024-02-06T18:06:53.23+00:00

Hi Friends, I was wondering is the listview header able to be formatted to contain a Label with text Search followed by a SerachBar. These two elements should be on the same line. Thanks !

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,701 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,100 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 77,181 Reputation points Microsoft Vendor
    2024-02-07T02:11:11.78+00:00

    Hello,

    Yes, Header of type object, specifies the string or view that will be displayed at the start of the list. You can put Label and SearchBar in the Listview.Header's Stacklayout like following code.

     <ListView>
          <ListView.Header>
              <StackLayout Orientation="Horizontal" BackgroundColor="LightGray">
                  <Label Margin="10,0,0,0" VerticalOptions="CenterAndExpand"
             Text="Search"
             FontSize="12"
             FontAttributes="Bold" />
                  <SearchBar/>
              </StackLayout>
          </ListView.Header>
          <ListView.ItemsSource>
              <x:Array Type="{x:Type x:String}">
                  <x:String>mono</x:String>
                  <x:String>monodroid</x:String>
                 
              </x:Array>
          </ListView.ItemsSource>
      </ListView>
    

    For more information, you can refer to this document: Display views in the header and footer

    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.


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.