Hey, I am trying to add a header to my listview. My listview contents will be a grid, so the column sizes will change dynamically. I have tried using listview.header, but the size of the header column is not related to the grid so does not size appropriately.
I have also tried adding another row in the grid. The first one being the header. But as expected, this duplicates for each row of the listview. Is there an easy way to do this, or to say, this is first row in listview, so only display header on this row?
Here is my code
<ListView ItemsSource="{Binding Orders}" HorizontalOptions="Center">
<ListView.Header>
<StackLayout Orientation="Horizontal" BackgroundColor="Black">
<Label Text="Product" />
<Label Text="Quantity" />
</StackLayout>
</ListView.Header>
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Style="{StaticResource GridInListViewStyle}" HorizontalOptions="Center" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="75"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Label Text="Product" BackgroundColor="Green" Grid.Column="0" Grid.Row="0" />
<Label Text="Quantity" BackgroundColor="Green" Grid.Column="1" Grid.Row="0"/>
<StackLayout Orientation="Horizontal" Grid.Column="0" Grid.Row="1" Padding="10, 0, 0, 0">
<Label Text="{Binding ProductName}" VerticalOptions="Center" />
</StackLayout>
<Entry Keyboard="Numeric" Grid.Column="1" Grid.Row="1" VerticalOptions="Center"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Attached is current layout
Thanks