Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Desktop] ItemsWrapGrid does not work in ListView.ItemsPanel when used as ItemsPanelTemplate #19062

Open
kucint opened this issue Dec 11, 2024 · 9 comments
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification

Comments

@kucint
Copy link

kucint commented Dec 11, 2024

Current behavior

define user control with following content:

<UserControl.Resources>
  <CollectionViewSource x:Name="CategoryCollectionViewSource" IsSourceGrouped="True" />
</UserControl.Resources>

<ListView ItemsSource="{x:Bind CategoryCollectionViewSource.View, Mode=OneWay}"
          SelectionMode="Single"
          ShowsScrollingPlaceholders="True"
          BorderThickness="{ThemeResource ListBoxBorderThemeThickness}"
          BorderBrush="{ThemeResource ListBoxBorderThemeBrush}"
          SelectedItem="{x:Bind SelectedItem, Mode=TwoWay}">

  <ListView.ItemsPanel>
    <ItemsPanelTemplate>
      <!--If the following line (<ItemsWrapGrid/>) will be commented out
      and the PRJ will be launched in net9.0-desktop mode,
      5 Items (A, B, C, D, E), will be displayed in a ListView.
      However, if the following line is active, nothing will be displayed.

      Note: In net9.0-windows it works as expected with and without that line.

      Our fazit: ItemsWrapGrid is not compatible with net9.0-desktop.-->

      <ItemsWrapGrid/>

    </ItemsPanelTemplate>
  </ListView.ItemsPanel>

  <ListView.ItemContainerStyle>
    <Style TargetType="ListViewItem" BasedOn="{StaticResource DefaultListViewItemStyle}">
      <Setter Property="MinWidth" Value="0"/>
      <Setter Property="Margin" Value="0,0"/>
      <Setter Property="Padding" Value="15,0,15,0"/>
    </Style>
  </ListView.ItemContainerStyle>

  <ListView.ItemTemplate>
    <DataTemplate x:DataType="local:Item">
      <TextBlock Text="{x:Bind Label}" HorizontalAlignment="Center"/>
    </DataTemplate>
  </ListView.ItemTemplate>

</ListView>

and use it in a Page:

<Grid>

    <acc:AccordionCtrl x:Name="AccordionCtrl"
                     Grid.Column="0" Grid.Row="0"
                     Margin="5"
                     HorizontalAlignment="Stretch"
                     VerticalAlignment="Stretch"/>

</Grid>

Expected behavior

this works correctly on WindowsAppSdk:
image

but fails on Desktop:
image

Apparently ItemsWrapGrid fails to display its content when used as a template in ListView.ItemsPanel

How to reproduce it (as minimally and precisely as possible)

MINIMAL REPRO PROJECT: MWEApp.zip

Workaround

none

Works on UWP/WinUI

Yes

Environment

No response

NuGet package version(s)

No response

Affected platforms

Skia (WPF)

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

"Uno.Sdk": "5.5.54"

Anything else we need to know?

No response

@kucint kucint added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Dec 11, 2024
@jeromelaban
Copy link
Member

jeromelaban commented Dec 11, 2024

Thanks the report. This is indeed currently not yet supported for desktop #4023. Using ItemsRepeater can be another way to implement this.

@DevTKSS
Copy link
Contributor

DevTKSS commented Dec 18, 2024

@jeromelaban can you tell the reason for it to not work or is it only the itemswrapgrid control which is just not jet available?

@MichaelJachan
Copy link

Dear Jerome! I am the coworker of Tomasz.

  1. In Desktop, the Control ItemsWrapGrid is "available", i.e., it compiles. But at runtime, it does not display. I guess, there is no implementation for it.

  2. What is your proposal of a workaround?

Best, Michael :)

@jeromelaban
Copy link
Member

jeromelaban commented Dec 18, 2024

  1. In Desktop, the Control ItemsWrapGrid is "available", i.e., it compiles. But at runtime, it does not display. I guess, there is no implementation for it.

Indeed, it's not implemented at this time.

What is your proposal of a workaround?

You can use the ItemsRepeater control and custom layouts to implement a wrap grid, such as the WrapLayout.

@MichaelJachan
Copy link

Good Morning! You said, ItemsWrapGrid is already implemented (also in Desktop)? When can we expect a bugfix?

Best, Michael

@jeromelaban
Copy link
Member

My apologies, my answer missed a not.

It's not a bug in this case, it's a missing feature. At this time this has not been prioritized by our clients and we do not have a timeline for an implementation.

@MichaelJachan
Copy link

OK. Then, I would urgently need a workaround, which replaces the ItemsWrapGrid, in order to implement an AccordionControl based on a ListView please:)

@MichaelJachan
Copy link

MichaelJachan commented Dec 19, 2024

@jeromelaban:

... for your overview, I have here collected the nature of the workaround using ItemsRepeader. The problem seems for me newbie to be with the ItemsSource for the ItemsRepeater.

First, I succeeded to use the ItemsRepeater as the Main Content of MySandboxControl:

    <ItemsRepeater ItemsSource="{x:Bind MyItems}">
      <ItemsRepeater.Layout>
        <UniformGridLayout Orientation="Horizontal" MinItemWidth="52"/>
      </ItemsRepeater.Layout>
    </ItemsRepeater>

And it does what is expected: 10 strings (MyItems) are displayed and wrapped according to the width of the window.

BUT SECOND, my actual case is more involved. The original ItemsWrapGrid is used within a ListView-ItemsPanelTemplate like that:

      <ListView.ItemsPanel>
        <ItemsPanelTemplate>

          <ItemsWrapGrid Orientation="Horizontal" GroupPadding="0,0" GroupHeaderPlacement="Top" AreStickyGroupHeadersEnabled="True"/>

        </ItemsPanelTemplate>
      </ListView.ItemsPanel>

THUS, I guess, I need to use the new ItemsRepeater like:

      <ListView.ItemsPanel>
        <ItemsPanelTemplate>

          <ItemsRepeater>
            <ItemsRepeater.Layout>
              <UniformGridLayout Orientation="Horizontal" MinItemWidth="52"/>
            </ItemsRepeater.Layout>
          </ItemsRepeater>

        </ItemsPanelTemplate>
      </ListView.ItemsPanel>

BUT I did not succeed to set an ItemsSource for the ItemsRepeater.

@jeromelaban
Copy link
Member

Thanks for the update. It's best if you open a discussion with your sample code, as it's not related to the ItemsWrapGrid issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

No branches or pull requests

4 participants