xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

[Bug] In a UWP AppShell app, using a CollectionView within a StackLayout along with a solitary label gives a blank screen. #12009

Open davefxy opened 4 years ago

davefxy commented 4 years ago

Description

In a UWP AppShell app, using a CollectionView within a StackLayout along with a solitary label gives a blank screen.

Steps to Reproduce

  1. I took the the xamarin xaminals sample app
  2. I edited the CatsPage.xaml adding a couple of lines like so: `
    <Label Text="Test" HorizontalOptions="Center" />
    <CollectionView Margin="20"
                ItemsSource="{x:Static data:CatData.Cats}"
                ItemTemplate="{StaticResource AnimalTemplate}"
                SelectionMode="Single"
                SelectionChanged="OnCollectionViewSelectionChanged" />

    `

  3. Run the modified sample, in the xaminals sample the 1st screen displayed is CatsPage.xaml. The content is black. If you uncomment the Button control, run again, the page is displayed as expected.

Basic Information

This was tested on a Windows PC using Visual Studio 2019 Version 16.7.2, Xamarin Forms v4.8.0.1364.

Screenshots

Without Button With Button

Reproduction Link

Workaround

bmacombe commented 4 years ago

@davefxy If you resize the window does it then display?

If so might be related to #8814

davefxy commented 4 years ago

Yes it does. Amazing workaround.

Sent from Mail for Windows 10

From: Brian Macomber Sent: Wednesday, September 2, 2020 3:45 PM To: xamarin/Xamarin.Forms Cc: Davefxy; Mention Subject: Re: [xamarin/Xamarin.Forms] [Bug] In a UWP AppShell app, using aCollectionView within a StackLayout along with a solitary label gives a blankscreen. (#12009)

@davefxy If you resize the window does it then display? If so might be related to #8814 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

davefxy commented 4 years ago

Why does having a button in stacklayout have the same effect as the window resize?

Sent from Mail for Windows 10

From: Brian Macomber Sent: Wednesday, September 2, 2020 3:45 PM To: xamarin/Xamarin.Forms Cc: Davefxy; Mention Subject: Re: [xamarin/Xamarin.Forms] [Bug] In a UWP AppShell app, using aCollectionView within a StackLayout along with a solitary label gives a blankscreen. (#12009)

@davefxy If you resize the window does it then display? If so might be related to #8814 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

bmacombe commented 4 years ago

@davefxy It's a layout timing issue when the CollectionView's item source is set.

PR #11394 is in review to fix.

hartez commented 3 years ago

Why does having a button in stacklayout have the same effect as the window resize?

My guess is that it's an image button, and the image loading is async. So once the image has loaded, the button resizes and causes a re-layout; essentially the same thing that's happening when you resize the window.

hartez commented 3 years ago

This and #8814 do indeed appear to be the same problem. It's something specific to Shell, and possibly related to the timing things we fixed in #12017.