How do I create a ListView in .NET MAUI?

Platform: .NET MAUI| Category: Controls

You can create a ListView by adding the `<ListView>` element in your XAML file or by creating an instance of `ListView` in your C# code.

XAML

<ListView>
     <ListView.ItemsSource>
         <x:Array Type="{x:Type x:String}">
             <x:String>Item 1</x:String>
             <x:String>Item 2</x:String>
             <x:String>Item 3</x:String>
         </x:Array>
     </ListView.ItemsSource>
 </ListView>  

OR

C#

var listView = new ListView();
listView.ItemsSource = new string[] { "Item 1", "Item 2", "Item 3" };
Content = listView;

Share with

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.