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

Support for ItemsWrapGrid #468

Open
yowl opened this issue Dec 22, 2018 · 19 comments
Open

Support for ItemsWrapGrid #468

yowl opened this issue Dec 22, 2018 · 19 comments
Labels
area/porting 🖨️ Categorizes an issue or PR as relevant for porting of WinUI code difficulty/challenging 🤯 Categorizes an issue for which the difficulty level is reachable with internals understanding kind/enhancement New feature or request platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform project/items 🧾 Categorizes an issue or PR as relevant to items (ItemsControl, ItemsRepeater, ...)

Comments

@yowl
Copy link
Contributor

yowl commented Dec 22, 2018

I'm submitting a...

  • Bug report (I searched for similar issues and did not find one)

Current behavior

ListView ItemsSource works in the playground, but seems to have a problem when the ItemsSource is changed after its rendered.

Expected behavior

ListView should redraw with all the items in its ItemsSource when the ItemsSource is changed (and notified)

Minimal reproduction of the problem with instructions

Clone https://github.com/yowl/UnoStandardRefTest/tree/wasmlistview and run the wasm head. Click the Load button and you should get 2 buttons as you do in the UWP head.

Environment

Nuget Package: Uno.UI

Package Version(s): 1.43.0-dev.564

Affected platform(s):
- [ ] iOS
- [ ] Android
- [ x] WebAssembly
- [ ] Windows
- [ ] Build tasks

Visual Studio
- [ ] 2017 (version: )
- [ ] 2017 Preview (version: )
- [ ] for Mac (version: )

Relevant plugins
- [ ] Resharper (version: )
@yowl
Copy link
Contributor Author

yowl commented Dec 26, 2018

Binding and x:Bind behave the same.

@jeromelaban
Copy link
Member

This may have been fixed by #484, could you revalidate with latest master ?

@jeromelaban jeromelaban added the kind/bug Something isn't working label Jan 11, 2019
@yowl
Copy link
Contributor Author

yowl commented Jan 11, 2019

image
I'm still just getting the one item shown with Uno.UI 1.43.0-dev.614

@yowl
Copy link
Contributor Author

yowl commented Jan 14, 2019

As a simplification you can remove the binding and change the Xaml to

        <ListView x:Name="lst"
                  Grid.Column="1">
            <ListView.ItemsPanel>
                <ItemsPanelTemplate>
                    <ItemsWrapGrid Orientation="Horizontal"/>
                </ItemsPanelTemplate>
            </ListView.ItemsPanel>
        </ListView>

And in the button click

        private void Load(object sender, RoutedEventArgs e)
        {
            ViewModel.Reports = new List<ReportEntity>
                         {
                             new ReportEntity
                             {
                                 Key = 1, Name="a"
                             },
                             new ReportEntity
                             {
                             Key = 2, Name="b"
                         }
                         };
            lst.ItemsSource = ViewModel.Reports;
            Console.WriteLine("list items " + lst.Items.Count);
        }

One item will appear and Items.Count shows 0

@yowl
Copy link
Contributor Author

yowl commented Jan 14, 2019

and simpler:

        private void Load(object sender, RoutedEventArgs e)
        {
            lst.ItemsSource = new string [] {"a", "b"};
            Console.WriteLine("list items " + lst.Items.Count);
        }

is the same. I see
https://github.com/nventive/Uno/blob/0a00b15b736983daa19474b8cb9fd667059ab2cd/src/Uno.UI/UI/Xaml/Controls/ItemsControl/ItemsControl.cs#L291
so can forget about Items.Count as that seems like a known difference

@carldebilly
Copy link
Member

I just realized the problem is not related to the Items: if you check in the DOM, you can see your 2 items are there. They are "just" not arranged correctly.

I'll continue my investigations to fix this problem...

@yowl
Copy link
Contributor Author

yowl commented Jan 16, 2019

When I wrote this I thought it was the Items so sorry if I misled you there.

@carldebilly
Copy link
Member

Source of the problem : ItemsWrapGrid is not implemented on Wasm. Only ItemsStackPanel is.

When a Panel is not implemented, only the first child gets measured & arranged, that's the default behavior of a FrameworkElement.

Possible workarounds:

  • Use a WrapPanel instead, if you only have few items, it will work without the virtualization.
  • Use the default ItemsStackPanel which is impletement on Wasm and will virtualize.
  • You can use conditional Xaml to use a WrapPanel only on Wasm.4

@carldebilly carldebilly changed the title wasm ListView ItemsSource does not update when changed [wasm] WrapGrid not supported Jan 21, 2019
@carldebilly carldebilly added kind/enhancement New feature or request platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform and removed kind/bug Something isn't working labels Jan 21, 2019
@carldebilly carldebilly changed the title [wasm] WrapGrid not supported [wasm] ItemsWrapGrid not supported Jan 21, 2019
@carldebilly carldebilly changed the title [wasm] ItemsWrapGrid not supported [wasm] ItemsWrapGrid not supported Jan 21, 2019
@yowl
Copy link
Contributor Author

yowl commented Jan 28, 2019

WrapPanel with Orientation="Horizontal" is ok, Vertical is not a great workaround because the ListView just lets it expand and never wraps. I can make do with Horizontal for now.

@DierkDroth
Copy link

  • Use a WrapPanel instead, if you only have few items, it will work without the virtualization.

This suggests that WrapPanel would be supported whereas here it says it would not be supported.

@jeromelaban would you mind providing clarification? Thanks in advance

@carldebilly carldebilly added the project/items 🧾 Categorizes an issue or PR as relevant to items (ItemsControl, ItemsRepeater, ...) label Feb 11, 2021
@davidjohnoliver
Copy link
Contributor

@DierkDroth WrapPanel isn't listed on the page you link to because it's not a UWP control. It's an Uno-only panel that provides a layout similar to ItemsWrapGrid, but without virtualization.

@DierkDroth
Copy link

@davidjohnoliver now I'm even confused more:

  • WrapPanel is listed on the page I linked above as "not supported"
  • WrapPanel appears to be a UWP control (pls see here)

What am I missing?

@davidjohnoliver
Copy link
Contributor

@davidjohnoliver now I'm even confused more:

  • WrapPanel is listed on the page I linked above as "not supported"
  • WrapPanel appears to be a UWP control (pls see here)

What am I missing?

  1. My question is what am I missing 😄 I Ctrl-F'ed that page and couldn't find "WrapPanel" anywhere. Are you looking at WrapGrid by chance?
  2. That WrapPanel you're linking to is a Windows Community Toolkit control, not from UWP itself. No relation to the WrapPanel defined in Uno (as far as I know).

@DierkDroth
Copy link

On 1): My apologies. Crossed eyes on my end
On 2): understand. Meaning the 'UNO version' of WrapPanel would work in the UNO UWP head as well?

@davidjohnoliver
Copy link
Contributor

On 2): understand. Meaning the 'UNO version' of WrapPanel would work in the UNO UWP head as well?

No it won't, it's not part of the Uno.UI.Toolkit pieces that are available on the UWP head. It should be conditionally used for WASM only, per Carl's earlier comment.

@DierkDroth
Copy link

Thanks for clarification

@jeromelaban
Copy link
Member

@DierkDroth there's a WrapPanel control available in the Windows Community Toolkit, if you need one available on all platforms.

@DierkDroth
Copy link

Thanks again @jeromelaban

@jeromelaban jeromelaban added the difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. label Feb 15, 2021
@davidjohnoliver davidjohnoliver changed the title [wasm] ItemsWrapGrid not supported [wasm] ItemsWrapGrid (virtualizing GridView) not supported Apr 28, 2021
@MartinZikmund MartinZikmund added difficulty/challenging 🤯 Categorizes an issue for which the difficulty level is reachable with internals understanding and removed difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. labels May 31, 2021
@SuperJMN
Copy link
Contributor

I thinks this #4023 is related with this issue.

@MartinZikmund MartinZikmund changed the title [wasm] ItemsWrapGrid (virtualizing GridView) not supported [WASM] Support for ItemsWrapGrid Oct 24, 2022
@MartinZikmund MartinZikmund added the area/porting 🖨️ Categorizes an issue or PR as relevant for porting of WinUI code label Jun 2, 2023
@MartinZikmund MartinZikmund changed the title [WASM] Support for ItemsWrapGrid Support for ItemsWrapGrid Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/porting 🖨️ Categorizes an issue or PR as relevant for porting of WinUI code difficulty/challenging 🤯 Categorizes an issue for which the difficulty level is reachable with internals understanding kind/enhancement New feature or request platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform project/items 🧾 Categorizes an issue or PR as relevant to items (ItemsControl, ItemsRepeater, ...)
Projects
None yet
Development

No branches or pull requests

7 participants