Windows Community Toolkit AdaptiveGridView incorrect behavior

123244 235 Reputation points
2025-01-24T13:00:01.3166667+00:00

Hi, has anyone had this problem when using AdaptiveGridView (Win UI platform). The elements do not want to expand to occupy the full width available for them in the row (I attach a photo). I'll leave you the code for setting the AdaptiveGridView so that you can see where the possible error is. If you know how to fix it, I will be glad to hear your suggestions.

Code Example:

<controls:AdaptiveGridView DesiredWidth="180"
                           ItemHeight="160"
                           StretchContentForSingleRow="True"
                           ItemsSource="{x:Bind GroupedViewSource.View, Mode=OneWay}">
    <GridView.ItemTemplate>
        <DataTemplate x:DataType="directory:IDirectoryItem">
            <Grid Padding="10,15"
                  Background="Yellow">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>

                <FontIcon VerticalAlignment="Center"
                          HorizontalAlignment="Center"
                          FontSize="20"
                          Glyph="&#xE721;" />

                <TextBlock Grid.Row="1"
                           Text="{x:Bind Name}" />
            </Grid>
        </DataTemplate>
    </GridView.ItemTemplate>
</controls:AdaptiveGridView>

Result:
photo_2025-01-24_14-56-17
photo_2025-01-24_14-46-15

Developer technologies | Universal Windows Platform (UWP)
Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | C#
Developer technologies | 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.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Junjie Zhu - MSFT 21,731 Reputation points
    2025-01-27T06:49:24.59+00:00

    Hello,

    Welcome to Microsoft Q&A!

    I was able to reproduce the same behavior, and this unexpected behavior has been reported on Github before.

    According to the Announcing Windows Community Toolkit v8.0, Microsoft.Toolkit.Uwp.UI.Controls has been deprecated as it is legacy and is no longer maintained. AdaptiveGridView has not been moved to the new package(CommunityToolkit.WinUI.UI.*). You can open a discussion to garner support for future migration or to get information on contributing to migrate it for everyone.

    In the meantime, it is recommended to use ItemsRepeater as an alternative.

    Thank you.


0 additional answers

Sort by: Most helpful

Your answer

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