Open smegleyshire2 opened 4 months ago
Hi I'm an AI powered bot that finds similar issues based off the issue title.
Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!
Note: You can give me feedback by thumbs upping or thumbs downing this comment.
This issue has been verified using Visual Studio 17.11.0 Preview 2.1(8.0.61 & 8.0.40). Can repro on iOS platform.
Thanks Winnie!
Description
I have linked to a small demo app that shows the issue. When run you see the following (Android):
Tap ADD ITEM a few times and a label for each item appears under the buttons:
The items are in a scroll view which starts scrolling when the view reaches a height of 350. Tap REMOVE ITEM to remove items from the bottom.
Now try running the demo app on iOS. No items appear but they are being created and you can see them in the visual tree inspector in Visual Studio.
XAML:
<?xml version="1.0" encoding="utf-8" ?> <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="BugDemoApp.MainPage">
Code:
using System.Collections.ObjectModel;
namespace BugDemoApp { public partial class MainPage : ContentPage { private ObservableCollection Items = new ObservableCollection();
}
Steps to Reproduce
See description above
Link to public reproduction project repository
https://github.com/smegleyshire2/MauiBugDemoApp
Version with bug
8.0.61 SR6.1
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
iOS
Affected platform versions
iOS 17.5
Did you find any workaround?
When ADD ITEM is tapped, I have to change the size of something on the page to force a re-layout. This causes the correct number of items to be displayed.
The buttons in the demo app are in a horizontal stack layout which is centred horizontally. I've found that tweaking the horizontal margin of that horizontal stack layout each time an item is added forces the re-layout to occur without moving the buttons (as its horizontally centred). So, if the horizontal stack layout is given a name:
x:Name="slButtons"
then doing this on each tap causes a re-layout and the items to update on iOS:
slButtons.Margin = (slButtons.Margin.Left == 0) ? new Thickness(1,0) : new Thickness(0);
Relevant log output
No response