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.ItemTemplate does not work with RecyclingElementFactory or IElementFactory

See original GitHub issue

Describe the bug I try to use the RecyclingElementFactory or IElementFactory as an ItemsRepeater.ItemTemplate but fail - app crashes. Doc here - https://docs.microsoft.com/ru-ru/uwp/api/microsoft.ui.xaml.controls.itemsrepeater.itemtemplate?view=winui-2.4

Steps to reproduce the bug

  1. Create xaml like following:
<ItemsRepeater ItemsSource="{x:Bind Items}">
	<ItemsRepeater.ItemTemplate>
		<RecyclingElementFactory/>
	</ItemsRepeater.ItemTemplate>
</ItemsRepeater>

Expected behavior All works fine.

Version Info NuGet package version: [Microsoft.WinUI 3.0.0-preview2.200713.0]

Windows app type:

UWP Win32
No Yes
Windows 10 version Saw the problem?
May 2020 Update (19041) Yes
Device form factor Saw the problem?
Desktop Yes

Additional context I have attached an example. App17.zip

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
zed220commented, Oct 21, 2020

I have mistaken. All works as expected. For example:

<ScrollViewer>
	<ItemsRepeater ItemsSource="{x:Bind Items}">
		<ItemsRepeater.ItemTemplate>
			<RecyclingElementFactory>
				<DataTemplate x:Key="item" x:DataType="local:Item">
					<TextBlock Text="{x:Bind Value}"/>
				</DataTemplate>
				<RecyclingElementFactory.RecyclePool>
					<RecyclePool/>
				</RecyclingElementFactory.RecyclePool>
			</RecyclingElementFactory>
		</ItemsRepeater.ItemTemplate>
	</ItemsRepeater>
</ScrollViewer>
public class Item : INotifyPropertyChanged {
	public string Value { get; set; }

	public event PropertyChangedEventHandler PropertyChanged;
}

Many thanks!

1reaction
ranjeshjcommented, Oct 20, 2020

@zed220 what is it you are trying to achieve by passing an empty data template ,selector or factory ? You can pass in a rectangle or something which is not visible which could achieve the same desired result perhaps ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

ItemsRepeater.ItemTemplate Property
Set this property to a factory object used to generate a UIElement for a given data item. This can be a DataTemplate, a...
Read more >
Items added to ItemsControl not using ItemTemplate
I'm trying to create a dashboard application which a user can customise by adding different controls (Tables, Graphs etc.) and move them around/ ......
Read more >
ItemsRepeater
A data-driven collection control that incorporates a flexible layout system, custom views, and virtualization. ItemsRepeater is a port of the UWP ItemsRepeater ......
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