Unwanted padding on ListViewItem in .net MAUI

Laradius 1 Reputation point
2022-07-06T11:53:41.13+00:00

0

I have created a ListView which is binded to desired items.

However, on each ListViewItem there is unwanted padding which i have checked in XAML visual preview (12,0,0,0)

However, I haven't found any way to set the padding to 0 for ListViewItem or ViewCell as they don't have those properties accessable. They are only accessable through xaml live visual preview.

Is there any way to remove the unwanted padding?

I'll include the picture for visualization (ListView has red background, and children have blue background) Picture showing the problem

<ListView ItemsSource="{Binding Items}" Background="Red">  
            <ListView.ItemTemplate>  
                <DataTemplate>  
                    <ViewCell>  
                        <Grid RowDefinitions="*" ColumnDefinitions="*">  
                            <Label Grid.Column="0" Grid.Row="0" BackgroundColor="Blue" HorizontalTextAlignment="Start" HorizontalOptions="Start" Text="Hello World"/>  
                        </Grid>  
                    </ViewCell>  
                </DataTemplate>  
            </ListView.ItemTemplate>  
        </ListView>  
Developer technologies | .NET | .NET MAUI
Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2022-07-07T06:11:34.507+00:00

    Hello,

    I've tested your code in Visual Studio 2022 Preview 17.2.0 with MAUI 6.0.300-rc.2.5513, and it works fine.

    I noticed that you have created an issue in GitHub: Non removable forced padding on each ListViewItem.

    Please keep following the progress on this issue.

    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.


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.