question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ItemsRepeater renders only the first item when no ScrollViewer in the visual tree under a popup

See original GitHub issue

Describe the bug If there is no ScrollViewer in the parent visual tree of an ItemsRepeater, then it will render only the first item.

Steps to reproduce the bug

  1. Create a blank app, in the MainPage put:

MainPage.xaml

<Grid>
	<Popup x:Name="popup" IsOpen="True">
		<controls:ItemsRepeater x:Name="SUT" />
	</Popup>
</Grid>

MainPage.xaml.cs

SUT.ItemsSource = Enumerable.Range(0, 10);

Expected behavior As the Popup is tall enough, we should see all 10 items.

Screenshots image

Version Info

  • Microsoft.UI.Xaml: 2.4.0-prerelease.200322001
  • Windows: 1909 18363.778_
  • Project’s target and min version: 18362
  • Device: Desktop

Additional context According to my tests, this is because in the ViewportManagerWithPlatformFeatures, if we cannot find any scroller we init the viewport with an empty rect. This drives the GetLayoutRealizationWindow to return an empty Rect. This “window” is used by the FlowLayoutAlgorithm.ShouldContinueFillingUpSpace(), which concludes that the viewport/window is full and stops the elements generation after the first one.

Note: this is not visible out of a Popup as a normal Window does have a ScrollViewer in its “template”.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
dr1rrbcommented, Apr 28, 2020

Hi @ranjeshj , yes it works:

<Grid>
	<Popup x:Name="popup" IsOpen="True">
		<ScrollViewer>
			<controls:ItemsRepeater x:Name="SUT" />
		</ScrollViewer>
	</Popup>
</Grid>

image

But it’s a valid use case to not use one. I would have fix it by myself, just I’m not a huge fan of C++ 😃

1reaction
dr1rrbcommented, Apr 28, 2020

The issue is that if there is no scroller we don’t even subscribe to the EffectiveViewportChanged event. So except if you plan that a root control (like the Popup in that case) implements IScrollAnchorProvider, I think that fixing #2102 would not fix this case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - WinUI 3 ItemsRepeater re-orders/removes items when ...
Open the page "ItemsRepeater Scroll Issue (re-order/remove)". Items are ordered correctly. Start scrolling up and down. Items are re-ordered and ...
Read more >
Using the ItemsRepeater property
ItemsRepeater generates code that allows you to display a collection of items in a customizable layout that can be repeated multiple times, think...
Read more >
ItemsRepeater - Windows apps
ItemsRepeater is a light-weight control to generate and present a collection of items.
Read more >
ScrollViewer Class (Microsoft.UI.Xaml.Controls)
Represents a scrollable area that can contain other visible elements. ... scope for this element, even if it's not in the visual tree...
Read more >
UWP | XAML Brewer, by Diederik Krols
In this article we describe the process of migrating a user control from UWP to WinUI 3. The subject is the Radial Gauge...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found